/** * Converts a dashicon into it's CSS * * @since 1.0.0 */ function wpex_dashicon_css_content($dashicon = '') { $css_content = 'f111'; if ($dashicon) { $dashicons = wpex_get_dashicons_array(); if (isset($dashicons[$dashicon])) { $css_content = $dashicons[$dashicon]; } } return $css_content; }
/** * Output for the actual Staff Editor admin page. * * @since 2.0.0 */ public function create_admin_page() { ?> <div class="wrap"> <h2><?php esc_html_e('Post Type Editor', 'total'); ?> </h2> <form method="post" action="options.php"> <?php settings_fields('wpex_staff_options'); ?> <table class="form-table"> <tr valign="top"> <th scope="row"><?php esc_html_e('Admin Icon', 'total'); ?> </th> <td> <?php // Mod $mod = wpex_get_mod('staff_admin_icon', null); $mod = 'groups' == $mod ? '' : $mod; // Dashicons list $dashicons = wpex_get_dashicons_array(); ?> <div id="wpex-dashicon-select" class="wpex-clr"> <?php foreach ($dashicons as $key => $val) { $value = 'groups' == $key ? '' : $key; $class = $mod == $value ? 'button-primary' : 'button-secondary'; ?> <a href="#" data-value="<?php echo esc_attr($value); ?> " class="<?php echo esc_attr($class); ?> " title="<?php echo esc_attr($key); ?> "><span class="dashicons dashicons-<?php echo $key; ?> "></span></a> <?php } ?> </div> <input type="hidden" name="wpex_staff_branding[staff_admin_icon]" id="wpex-dashicon-select-input" value="<?php echo esc_attr($mod); ?> "></td> </td> </tr> <tr valign="top"> <th scope="row"><?php esc_html_e('Post Type: Name', 'total'); ?> </th> <td><input type="text" name="wpex_staff_branding[staff_labels]" value="<?php echo wpex_get_mod('staff_labels'); ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php esc_html_e('Post Type: Singular Name', 'total'); ?> </th> <td><input type="text" name="wpex_staff_branding[staff_singular_name]" value="<?php echo wpex_get_mod('staff_singular_name'); ?> " /></td> </tr> <tr valign="top"> <th scope="row"><?php esc_html_e('Post Type: Slug', 'total'); ?> </th> <td><input type="text" name="wpex_staff_branding[staff_slug]" value="<?php echo wpex_get_mod('staff_slug'); ?> " /></td> </tr> <tr valign="top" id="wpex-tags-enable"> <th scope="row"><?php esc_html_e('Enable Tags', 'total'); ?> </th> <?php // Get checkbox value $mod = wpex_get_mod('staff_tags', 'on'); $mod = 'off' != $mod ? 'on' : 'off'; // sanitize ?> <td><input type="checkbox" name="wpex_staff_branding[staff_tags]" value="<?php echo esc_attr($mod); ?> " <?php checked($mod, 'on'); ?> /></td> </tr> <tr valign="top" id="wpex-tags-label"> <th scope="row"><?php esc_html_e('Tags: Label', 'total'); ?> </th> <td><input type="text" name="wpex_staff_branding[staff_tag_labels]" value="<?php echo wpex_get_mod('staff_tag_labels'); ?> " /></td> </tr> <tr valign="top" id="wpex-tags-slug"> <th scope="row"><?php esc_html_e('Tags: Slug', 'total'); ?> </th> <td><input type="text" name="wpex_staff_branding[staff_tag_slug]" value="<?php echo wpex_get_mod('staff_tag_slug'); ?> " /></td> </tr> <tr valign="top" id="wpex-categories-enable"> <th scope="row"><?php esc_html_e('Enable Categories', 'total'); ?> </th> <?php // Get checkbox value $mod = wpex_get_mod('staff_categories', 'on'); $mod = 'off' != $mod ? 'on' : 'off'; // sanitize ?> <td><input type="checkbox" name="wpex_staff_branding[staff_categories]" value="<?php echo esc_attr($mod); ?> " <?php checked($mod, 'on'); ?> /></td> </tr> <tr valign="top" id="wpex-categories-label"> <th scope="row"><?php esc_html_e('Categories: Label', 'total'); ?> </th> <td><input type="text" name="wpex_staff_branding[staff_cat_labels]" value="<?php echo wpex_get_mod('staff_cat_labels'); ?> " /></td> </tr> <tr valign="top" id="wpex-categories-slug"> <th scope="row"><?php esc_html_e('Categories: Slug', 'total'); ?> </th> <td><input type="text" name="wpex_staff_branding[staff_cat_slug]" value="<?php echo wpex_get_mod('staff_cat_slug'); ?> " /></td> </tr> </table> <?php submit_button(); ?> </form> <script> ( function( $ ) { "use strict"; $( document ).ready( function() { // Dashicons var $buttons = $( '#wpex-dashicon-select a' ), $input = $( '#wpex-dashicon-select-input' ); $buttons.click( function() { var $activeButton = $( '#wpex-dashicon-select a.button-primary' ); $activeButton.removeClass( 'button-primary' ).addClass( 'button-secondary' ); $( this ).addClass( 'button-primary' ); $input.val( $( this ).data( 'value' ) ); return false; } ); // Categories enable/disable var $catsEnable = $( '#wpex-categories-enable input' ), $CatsTrToHide = $( '#wpex-categories-label, #wpex-categories-slug' ); if ( 'off' == $catsEnable.val() ) { $CatsTrToHide.hide(); } $( $catsEnable ).change(function () { if ( $( this ).is( ":checked" ) ) { $CatsTrToHide.show(); } else { $CatsTrToHide.hide(); } } ); // Tags enable/disable var $tagsEnable = $( '#wpex-tags-enable input' ), $tagsTrToHide = $( '#wpex-tags-label, #wpex-tags-slug' ); if ( 'off' == $tagsEnable.val() ) { $tagsTrToHide.hide(); } $( $tagsEnable ).change(function () { if ( $( this ).is( ":checked" ) ) { $tagsTrToHide.show(); } else { $tagsTrToHide.hide(); } } ); } ); } ) ( jQuery ); </script> </div> <?php }