Changeset 2176551
- Timestamp:
- 10/20/2019 10:05:46 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ultimate-hover-effects/trunk/admin/cmb2/example-functions.php
r2176547 r2176551 3 3 * Include and setup custom metaboxes and fields. (make sure you copy this file to outside the CMB2 directory) 4 4 * 5 * Be sure to replace all instances of ' yourprefix_' with your project's prefix.5 * Be sure to replace all instances of 'uhe_' with your project's prefix. 6 6 * http://nacin.com/2010/05/11/in-wordpress-prefix-everything/ 7 7 * … … 29 29 * @return bool True if metabox should show 30 30 */ 31 function yourprefix_show_if_front_page( $cmb ) {31 function uhe_show_if_front_page( $cmb ) { 32 32 // Don't show this metabox if it's not the front page template. 33 33 if ( get_option( 'page_on_front' ) !== $cmb->object_id ) { … … 44 44 * @return bool True if metabox should show 45 45 */ 46 function yourprefix_hide_if_no_cats( $field ) {46 function uhe_hide_if_no_cats( $field ) { 47 47 // Don't show this field if not in the cats category. 48 48 if ( ! has_tag( 'cats', $field->object_id ) ) { … … 58 58 * @param CMB2_Field $field The field object. 59 59 */ 60 function yourprefix_render_row_cb( $field_args, $field ) {60 function uhe_render_row_cb( $field_args, $field ) { 61 61 $classes = $field->row_classes(); 62 62 $id = $field->args( 'id' ); … … 80 80 * @param CMB2_Field $field The field object. 81 81 */ 82 function yourprefix_display_text_small_column( $field_args, $field ) {82 function uhe_display_text_small_column( $field_args, $field ) { 83 83 ?> 84 84 <div class="custom-column-display <?php echo esc_attr( $field->row_classes() ); ?>"> … … 95 95 * @param CMB2_Field $field Field object. 96 96 */ 97 function yourprefix_before_row_if_2( $field_args, $field ) {97 function uhe_before_row_if_2( $field_args, $field ) { 98 98 if ( 2 == $field->object_id ) { 99 99 echo '<p>Testing <b>"before_row"</b> parameter (on $post_id 2)</p>'; … … 103 103 } 104 104 105 add_action( 'cmb2_admin_init', ' yourprefix_register_demo_metabox' );105 add_action( 'cmb2_admin_init', 'uhe_register_demo_metabox' ); 106 106 /** 107 107 * Hook in and add a demo metabox. Can only happen on the 'cmb2_admin_init' or 'cmb2_init' hook. 108 108 */ 109 function yourprefix_register_demo_metabox() {109 function uhe_register_demo_metabox() { 110 110 $prefix = 'uhe_'; 111 111 … … 117 117 'title' => esc_html__( 'Hover Effects Options', 'cmb2' ), 118 118 'object_types' => array( 'u_hover_effect' ), // Post type 119 // 'show_on_cb' => ' yourprefix_show_if_front_page', // function should return a bool value119 // 'show_on_cb' => 'uhe_show_if_front_page', // function should return a bool value 120 120 // 'context' => 'normal', 121 121 // 'priority' => 'high', … … 124 124 // 'closed' => true, // true to keep the metabox closed by default 125 125 // 'classes' => 'extra-class', // Extra cmb2-wrap classes 126 // 'classes_cb' => ' yourprefix_add_some_classes', // Add classes through a callback.126 // 'classes_cb' => 'uhe_add_some_classes', // Add classes through a callback. 127 127 128 128 /* … … 411 411 * } 412 412 */ 413 function yourprefix_options_page_message_callback( $cmb, $args ) {413 function uhe_options_page_message_callback( $cmb, $args ) { 414 414 if ( ! empty( $args['should_notify'] ) ) { 415 415 … … 433 433 * @return bool Whether this box and its fields are allowed to be viewed. 434 434 */ 435 function yourprefix_limit_rest_view_to_logged_in_users( $is_allowed, $cmb_controller ) {435 function uhe_limit_rest_view_to_logged_in_users( $is_allowed, $cmb_controller ) { 436 436 if ( ! is_user_logged_in() ) { 437 437 $is_allowed = false; … … 441 441 } 442 442 443 add_action( 'cmb2_init', ' yourprefix_register_rest_api_box' );443 add_action( 'cmb2_init', 'uhe_register_rest_api_box' ); 444 444 /** 445 445 * Hook in and add a box to be available in the CMB2 REST API. Can only happen on the 'cmb2_init' hook. 446 446 * More info: https://github.com/CMB2/CMB2/wiki/REST-API 447 447 */ 448 function yourprefix_register_rest_api_box() {449 $prefix = ' yourprefix_rest_';448 function uhe_register_rest_api_box() { 449 $prefix = 'uhe_rest_'; 450 450 451 451 $cmb_rest = new_cmb2_box( array( … … 456 456 // Optional callback to limit box visibility. 457 457 // See: https://github.com/CMB2/CMB2/wiki/REST-API#permissions 458 // 'get_box_permissions_check_cb' => ' yourprefix_limit_rest_view_to_logged_in_users',458 // 'get_box_permissions_check_cb' => 'uhe_limit_rest_view_to_logged_in_users', 459 459 ) ); 460 460
Note: See TracChangeset
for help on using the changeset viewer.