Plugin Directory

Changeset 2176551


Ignore:
Timestamp:
10/20/2019 10:05:46 PM (6 years ago)
Author:
wpeffects
Message:

updated file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ultimate-hover-effects/trunk/admin/cmb2/example-functions.php

    r2176547 r2176551  
    33 * Include and setup custom metaboxes and fields. (make sure you copy this file to outside the CMB2 directory)
    44 *
    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.
    66 * http://nacin.com/2010/05/11/in-wordpress-prefix-everything/
    77 *
     
    2929 * @return bool      True if metabox should show
    3030 */
    31 function yourprefix_show_if_front_page( $cmb ) {
     31function uhe_show_if_front_page( $cmb ) {
    3232    // Don't show this metabox if it's not the front page template.
    3333    if ( get_option( 'page_on_front' ) !== $cmb->object_id ) {
     
    4444 * @return bool              True if metabox should show
    4545 */
    46 function yourprefix_hide_if_no_cats( $field ) {
     46function uhe_hide_if_no_cats( $field ) {
    4747    // Don't show this field if not in the cats category.
    4848    if ( ! has_tag( 'cats', $field->object_id ) ) {
     
    5858 * @param  CMB2_Field $field      The field object.
    5959 */
    60 function yourprefix_render_row_cb( $field_args, $field ) {
     60function uhe_render_row_cb( $field_args, $field ) {
    6161    $classes     = $field->row_classes();
    6262    $id          = $field->args( 'id' );
     
    8080 * @param  CMB2_Field $field      The field object.
    8181 */
    82 function yourprefix_display_text_small_column( $field_args, $field ) {
     82function uhe_display_text_small_column( $field_args, $field ) {
    8383    ?>
    8484    <div class="custom-column-display <?php echo esc_attr( $field->row_classes() ); ?>">
     
    9595 * @param  CMB2_Field $field      Field object.
    9696 */
    97 function yourprefix_before_row_if_2( $field_args, $field ) {
     97function uhe_before_row_if_2( $field_args, $field ) {
    9898    if ( 2 == $field->object_id ) {
    9999        echo '<p>Testing <b>"before_row"</b> parameter (on $post_id 2)</p>';
     
    103103}
    104104
    105 add_action( 'cmb2_admin_init', 'yourprefix_register_demo_metabox' );
     105add_action( 'cmb2_admin_init', 'uhe_register_demo_metabox' );
    106106/**
    107107 * Hook in and add a demo metabox. Can only happen on the 'cmb2_admin_init' or 'cmb2_init' hook.
    108108 */
    109 function yourprefix_register_demo_metabox() {
     109function uhe_register_demo_metabox() {
    110110    $prefix = 'uhe_';
    111111
     
    117117        'title'         => esc_html__( 'Hover Effects Options', 'cmb2' ),
    118118        'object_types'  => array( 'u_hover_effect' ), // Post type
    119         // 'show_on_cb' => 'yourprefix_show_if_front_page', // function should return a bool value
     119        // 'show_on_cb' => 'uhe_show_if_front_page', // function should return a bool value
    120120        // 'context'    => 'normal',
    121121        // 'priority'   => 'high',
     
    124124        // 'closed'     => true, // true to keep the metabox closed by default
    125125        // '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.
    127127
    128128        /*
     
    411411 * }
    412412 */
    413 function yourprefix_options_page_message_callback( $cmb, $args ) {
     413function uhe_options_page_message_callback( $cmb, $args ) {
    414414    if ( ! empty( $args['should_notify'] ) ) {
    415415
     
    433433 * @return bool                 Whether this box and its fields are allowed to be viewed.
    434434 */
    435 function yourprefix_limit_rest_view_to_logged_in_users( $is_allowed, $cmb_controller ) {
     435function uhe_limit_rest_view_to_logged_in_users( $is_allowed, $cmb_controller ) {
    436436    if ( ! is_user_logged_in() ) {
    437437        $is_allowed = false;
     
    441441}
    442442
    443 add_action( 'cmb2_init', 'yourprefix_register_rest_api_box' );
     443add_action( 'cmb2_init', 'uhe_register_rest_api_box' );
    444444/**
    445445 * Hook in and add a box to be available in the CMB2 REST API. Can only happen on the 'cmb2_init' hook.
    446446 * More info: https://github.com/CMB2/CMB2/wiki/REST-API
    447447 */
    448 function yourprefix_register_rest_api_box() {
    449     $prefix = 'yourprefix_rest_';
     448function uhe_register_rest_api_box() {
     449    $prefix = 'uhe_rest_';
    450450
    451451    $cmb_rest = new_cmb2_box( array(
     
    456456        // Optional callback to limit box visibility.
    457457        // 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',
    459459    ) );
    460460
Note: See TracChangeset for help on using the changeset viewer.