function beardbot_plugin_activation() {
if ( ! current_user_can( 'activate_plugins' ) ) return;
global $wpdb;
if ( null === $wpdb->get_row( "SELECT post_name FROM {$wpdb->prefix}posts WHERE post_name = 'search'", 'ARRAY_A' ) ) {
$current_user = wp_get_current_user();
// create post object
$page = array(
'post_title' => __( 'Search' ),
'post_status' => 'publish',
'post_author' => $current_user->ID,
'post_type' => 'page',
'post_content' =>'[WPS_BUS_SEARCH_FORM]',
);
// insert the post into the database
wp_insert_post( $page );
}
}
register_activation_hook( __FILE__, array(&$this,'beardbot_plugin_activation' ));
refrence link for theme
Refrence Link For Plugin
if ( ! current_user_can( 'activate_plugins' ) ) return;
global $wpdb;
if ( null === $wpdb->get_row( "SELECT post_name FROM {$wpdb->prefix}posts WHERE post_name = 'search'", 'ARRAY_A' ) ) {
$current_user = wp_get_current_user();
// create post object
$page = array(
'post_title' => __( 'Search' ),
'post_status' => 'publish',
'post_author' => $current_user->ID,
'post_type' => 'page',
'post_content' =>'[WPS_BUS_SEARCH_FORM]',
);
// insert the post into the database
wp_insert_post( $page );
}
}
register_activation_hook( __FILE__, array(&$this,'beardbot_plugin_activation' ));
refrence link for theme
Refrence Link For Plugin
Comments
Post a Comment