This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// verify meta box nonce | |
if ( !isset( $_POST['food_meta_box_nonce'] ) || !wp_verify_nonce( $_POST['food_meta_box_nonce'], basename( __FILE__ ) ) ){ | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// return if autosave | |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){ | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Check the user's permissions. | |
if ( ! current_user_can( 'edit_post', $post_id ) ){ | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// store custom fields values | |
// cholesterol string | |
if ( isset( $_REQUEST['cholesterol'] ) ) { | |
update_post_meta( $post_id, '_food_cholesterol', sanitize_text_field( $_POST['cholesterol'] ) ); | |
} | |
// store custom fields values | |
// carbohydrates string | |
if ( isset( $_REQUEST['carbohydrates'] ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// an array of values | |
$vitamins = array( 'Vitamin A', 'Thiamin (B1)', 'Riboflavin (B2)', 'Niacin (B3)', 'Pantothenic Acid (B5)', 'Vitamin B6', 'Vitamin B12', 'Vitamin C', 'Vitamin D', 'Vitamin E', 'Vitamin K' ); | |
// stores _food_vitamins array | |
$current_vitamins = ( get_post_meta( $post->ID, '_food_vitamins', true ) ) ? get_post_meta( $post->ID, '_food_vitamins', true ) : array(); | |
?> | |
<div class='inside'> | |
<h3><?php _e( 'Vitamins', 'food_example_plugin' ); ?></h3> | |
<p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php add_filter( 'show_admin_bar', '__return_false' ); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function myplugin_customize_toolbar( $wp_admin_bar ){ | |
// your code here | |
} | |
add_action( 'admin_bar_menu', 'myplugin_customize_toolbar', 999 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<li id="wp-admin-bar-user-url"> | |
<a class="ab-item" href="http://example.com"> | |
<span class="user-url">My Website</span> | |
</a> | |
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Customize WordPress Toolbar | |
* | |
* @param obj $wp_admin_bar An instance of the global object WP_Admin_Bar | |
*/ | |
function myplugin_customize_toolbar( $wp_admin_bar ){ | |
$user = wp_get_current_user(); | |
if ( ! ( $user instanceof WP_User ) ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Remove WordPress Toolbar for all users except admins and editors | |
* | |
*/ | |
function mytheme_remove_admin_bar() { | |
if ( ! current_user_can( 'publish_posts' ) ) { | |
show_admin_bar( false ); | |
} | |
} |