My plugin creates custom widgets, How can I programatically add them to existing sidebar widget areas?

Sidebars are registered in the option ‘sidebars_widgets’. To see what’s in and what not, try this: add_action( ‘wp_footer’, ‘show_my_sidebars’ ); function show_my_sidebars() { $sw = get_option( ‘sidebars_widgets’ ); print ‘<pre>’ . htmlspecialchars( print_r( $sw, TRUE ) ) . ‘</pre>’; } Sample output: Array ( [sidebar-footer-left] => Array ( [0] => archives-3 ) [sidebar-footer-right] => Array … Read more

Set page to draft on plugin deactivation

I’m posting this as another solution for you and its based on the page id /* $post_id – The ID of the post you’d like to change. $status – The post status publish|pending|draft|private|static|object|attachment|inherit|future|trash. */ function change_post_status($post_id,$status){ $current_post = get_post( $post_id, ‘ARRAY_A’ ); $current_post[‘post_status’] = $status; return wp_update_post($current_post); } So once you have this function you … Read more

How to properly create table in plugin

I see two problems- $this->table_name = $wpdb->prefix . “b99_pf”; $sql = “CREATE TABLE ” . $table_name . ” ( $table_name will be undefined, should be $this->table_name and in your query: cat tinytext default NOT NULL I don’t think it’ll like that default in there. EDIT – to answer your debug question- xdebug, xdebug and netbeans

can’t access some WordPress function from my plugin

First, since the if (!function_exists(‘check_admin_referer’)) echo “<h1>check_admin_referer not found</h1>”; code is working, then you’ve eliminated the issue being proper including of your Plugin sub-file. Second, all four of those functions are core WordPress functions, so you should never get a call to undefined function error for any of them. Can you post your relevant Plugin … Read more