I managed to have a working Admin Page with a checkbox (result is correcty stored in database) but I can’t figure how to execute some piece of code only if is checked… Found nothing related to checkbox in tutorials.
Tried this with no succes:
if (AdminPageFramework::getOption( 'MyPluginName', 'my_checkbox_2', '1' )) {
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );
} else {}
In fact, the code is always executed. Not only when the option is checked…
Somebody has an idea?
Here is a gist with my full plugin code
https://gist.github.com/bugsysop/5b81d62ae49415df4e9c3cc657964118
global $post;
$attachmenturl = get_post_meta( $post->ID, 'wcpoa_attachment_ext_url', true);
$attachmentname = get_post_meta( $post->ID, 'wcpoa_attachment_name', true);
$args = array(
'posts_per_page' => -1,
'orderby' => 'post_date',
'order' => 'DESC',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'wcpoa_attachment_ext_url',
'compare' => 'EXISTS',
),
array(
'key' => 'wcpoa_attachment_name',
'compare' => 'EXISTS',
),
),
);
foreach($attachmenturl as $key=>$val)
{
echo $val . "<br />";
}
]]>I’m currently doing a migration from an old theme to a new theme, and I’m in a big trouble.
My old theme (Newspaper from tagdiv) has a field with a Video option for the posts. When I put a video URL, the video shows at the begining of the post (magic!)
Now, I want to migrate this video field to my new theme. For do that, first I have done a custom field on my new theme for insert the Video URL and show it on the posts. (and it works!)
But my big trouble and the only problem that I have is when I try to export this field with WP All Export -Import plugin. I have this on MySQL Database “wp_postmeta“‘s table:
INSERT INTO
wp_postmeta(
meta_id,
post_id,
meta_key,
meta_value`) VALUES
(213286, 18405, ‘td_post_video’, ‘a:1:{s:8:”td_video”;s:27:”https://vimeo.com/273779372″;}’),`
How the hell I can “extract” the Vimeo URL and POst ID to do later the import to my new Video field on my new theme ??? I think this is an array or something else. I study MySQL, but this escapes my knowledge. Crazy!
Thank you very much in advance.
]]>I’m experiencing some difficulties with the pluggin of Watson Assistant. In the assistant I designed, I operate with arrays to store some words that the user says along the conversation, specificly I operate with the append() function. The problem is when I want to add a new word to my Array, the assistant stops working and I can’t continue the dialog. I have searched in the inspect panel of my browser and I found this error in the Network section:
In the response of the server when I add a new word, following the path: output – debug – log_messages – 0 :
level: “error”
message: “Error when updating context with context of dialog node id [node_4_1571658128621]. Dialog Node context is [{“wordList”:”<? $wordList.append(‘A’) ?>”}].?SpEL evaluation error: Expression [ $wordList.append(‘A’) ] converted to [ context[‘wordList’].append(‘A’) ] at position 21: EL1004E: Method call: Method append(String) cannot be found on JsonObject type?”
node_id: “node_4_1571658128621”
node_title: “Show List”
This example right here It’s a simple test to find out that the problem is here, because it works in “Try it out” and “Link Preview”. I have already reported this to IBM and they said that If the error can’t be duplicated in the two previous scenarios, I need to report it here. Also seems that It’s something I’m typing wrongly when I’m asigning the variables, but It works on the tests.
Thank you in advance.
]]><script>var custom = {"status":"new","type":"depend","url":"https:\/\/www.exemple.com"};</script>
My code in functions.php :
function resources() {
wp_register_script('custom_js', get_stylesheet_directory_uri().'/assets/js/custom.js', array('jquery'), '', TRUE);
wp_register_style( 'custom_css', get_stylesheet_directory_uri() . '/assets/css/custom.css', array(), '1', 'all' );
}
add_action( 'init', 'resources' );
function new_shortcode($atts){
if (!empty($atts)) {
$atts['url'] = MAIN_URL;
wp_localize_script('custom_js', 'custom', $atts);
}
wp_enqueue_script("custom_js");
wp_enqueue_style("custom_css");
}
add_shortcode('custom', 'new_shortcode');
Is there another way to do this without printing the data in script tag ?
]]>I’m wondering get the raw value of a relationship field with an array my code is:
function ver_assets () {
$formacion_assets = pods( 'formacion', get_the_id() );
$argu = array(
'name' => 'assets_activos',
'single' => false,
'raw' => false,
'in_form' => true,
'raw_display' => false,
'display' => false,
'get_meta' => false,
'output' => null,
'deprecated' => false,
);
$insertar_assets = $formacion_assets->field( $argu );
echo '<p>' . $insertar_assets . '</p>';
}
add_shortcode ('assets_sc', 'ver_assets');
The thing is that if a set to true “in_form” the call returns me for example (in this case the relationship field is with a pod, in this case returns me the post id with the in_form): “1234 and 5678” Then I want that returns me “1234, 5678” I really don’t figure it out how to achieve this. Thanks of beforehand.
]]>Also is it possible to populate a select field with the contents of an array. i.e., to take my example, have a drop-down select box with all usernames so that the admin can edit details for a specific user. I’ve just installed this extension but found that Contact Form 7 doesn’t seem to work very well with processing some PHP scripts…
Any help would be great. Thanks!
]]>