Delete a specific item menu when I deactivate my plugin
WordPress automatically handles that if you force delete the page instead of thrashing it. The following function takes a parameter to force delete -> wp_delete_post( $postid, $force_delete )
WordPress automatically handles that if you force delete the page instead of thrashing it. The following function takes a parameter to force delete -> wp_delete_post( $postid, $force_delete )
The best way to include an external library is to put it in your plugins folder. Then just use require_once() wherever you need it. Depending on the size of the plugin and your type of programing this might be in the main plugin file or wherever you need that functionality.
You can access the database with an INSERT statement and add multiple rows at once. Something like this pseudo-code: INSERT INTO $wpdb->posts ( `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_status`, `post_name`, `post_modified`, `guid`, `post_type`, `post_mime_type` ) VALUES ( $user_id, $current_date,$current_date_gmt, $content1 ), ( $user_id, $current_date,$current_date_gmt, $content2 ), ( $user_id, $current_date,$current_date_gmt, $content3 ) ; Make sure to … Read more
$_registered_pages is a temporary container for all registered admin menu pages. It is filled in add_menu_page() and add_submenu_page() and used used later in user_can_access_admin_page(). The leading underscore indicates you should not use it for anything. It is private and might change its name any time without warning. So do not use it in your own … Read more
You have to filter ‘get_comment’. The filter is part of the function with the same name. It is called in wp-admin/comment.php?action=editcomment and the comment is passed to the edit form where you see the email. The parameter is a comment object, you can change the email value here.
First, your callback must be PHP: function myjsfunction_callback() { ?> <script>myjsfunction();</script> <?php } Second, you can add multiple callbacks to one action: add_action( ‘myhelp’, ‘myjsfunction_callback’ ); add_action( ‘myhelp’, ‘mysecondfunction’ ); Now, you can call do_action() without parameter … do_action( ‘myhelp’ ); … and both callbacks will be executed. I reply to your comment: You can … Read more
Turns out I’m just silly. WP_Error was the undefined method, not resize. I was sending a bad image location through the resize function. How silly of me! It was working all along. I’ve included this on top $parse_uri = explode( ‘wp-content’, $_SERVER[‘SCRIPT_FILENAME’] ); require_once( $parse_uri[0] . ‘wp-load.php’ ); and this is my image resize function … Read more
check_admin_referer is a pluggable function which means it is defined after plugins are loaded so call your constructor or instantiate the object after or using plugins_loaded action hook. ex: class MyClass{ function __construct(){ if( isset($_POST[‘my_nonce_field’]) && check_admin_referer(‘my_nonce_action’, ‘my_nonce_field’)) $this->update_item(); } } add_action(‘plugins_loaded’,’newobj’); function newobj(){ $myclass = new MyClass; }
Found the answer. I hope this would be useful to others that might have this problem in the future. All you have to do is remove the content_save_pre filter and content_filtered_save_pre this will remove all Kses input form content filters. //temporarily disable remove_filter(‘content_save_pre’, ‘wp_filter_post_kses’); remove_filter(‘content_filtered_save_pre’, ‘wp_filter_post_kses’); wp_update_post($post); //bring it back once you’re done posting add_filter(‘content_save_pre’, … Read more
I am assuming you have a way to generate the attachment ID when inserting the image. You can then use the attachment ID to populate the input value. Are you not talking about an on-page input field? Try something like this: <?php //First get the attachment ID $attachment_id = 8; ?> <input type=”text” name=”tj_image_url” id=”tj_image_url” … Read more