/** * @param $post */ function vantage_menu_icon_metabox_render($post) { $icons = (include get_template_directory() . '/fontawesome/icons.php'); $sections = (include get_template_directory() . '/fontawesome/icon-sections.php'); $current = get_post_meta($post->ID, 'vantage_menu_icon', true); if (!empty($current)) { $current = apply_filters('vantage_fontawesome_icon_name', $current); } ?> <select name="vantage_menu_icon"> <option value="" <?php selected($current); ?> ><?php esc_html_e('None', 'vantage'); ?> </option> <?php foreach ($icons as $section => $s_icons) { ?> <?php if (isset($sections[$section])) { ?> <optgroup label="<?php echo esc_attr($sections[$section]); ?> "><?php } ?> <?php foreach ($s_icons as $icon) { ?> <option value="<?php echo esc_attr($icon); ?> " <?php selected($current, $icon); ?> ><?php echo esc_html(vantage_icon_get_name($icon)); ?> </option> <?php } ?> </optgroup> <?php } ?> </select> <?php wp_nonce_field('save_post_icon', '_vantage_menuicon_nonce'); }
/** * Display the circle icon widget form. * * @param array $instance * @return string|void */ public function form($instance) { $instance = wp_parse_args($instance, array('title' => '', 'text' => '', 'icon' => '', 'image' => '', 'icon_position' => 'top', 'icon_size' => 'small', 'icon_background_color' => '', 'more' => '', 'more_url' => '', 'all_linkable' => false, 'box' => false)); $icons = (include get_template_directory() . '/fontawesome/icons.php'); $sections = (include get_template_directory() . '/fontawesome/icon-sections.php'); if (!empty($instance['icon'])) { $instance['icon'] = apply_filters('vantage_fontawesome_icon_name', $instance['icon']); } ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title', 'vantage'); ?> </label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo esc_attr($instance['title']); ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('text'); ?> "><?php _e('Text', 'vantage'); ?> </label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('text'); ?> " name="<?php echo $this->get_field_name('text'); ?> " value="<?php echo esc_attr($instance['text']); ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('icon'); ?> "><?php _e('Icon', 'vantage'); ?> </label> <select id="<?php echo $this->get_field_id('icon'); ?> " name="<?php echo $this->get_field_name('icon'); ?> "> <option value="" <?php selected(!empty($instance['icon'])); ?> ><?php esc_html_e('None', 'vantage'); ?> </option> <?php foreach ($icons as $section => $s_icons) { ?> <?php if (isset($sections[$section])) { ?> <optgroup label="<?php echo esc_attr($sections[$section]); ?> "><?php } ?> <?php foreach ($s_icons as $icon) { ?> <option value="<?php echo esc_attr($icon); ?> " <?php selected($instance['icon'], $icon); ?> ><?php echo esc_html(vantage_icon_get_name($icon)); ?> </option> <?php } ?> </optgroup> <?php } ?> </select> </p> <p> <label for="<?php echo $this->get_field_id('icon_background_color'); ?> "><?php _e('Icon Background Color', 'vantage'); ?> </label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('icon_background_color'); ?> " name="<?php echo $this->get_field_name('icon_background_color'); ?> " value="<?php echo esc_attr($instance['icon_background_color']); ?> " /> <span class="description"><?php _e('A hex color', 'vantage'); ?> </span> </p> <p> <label for="<?php echo $this->get_field_id('image'); ?> "><?php _e('Circle Background Image URL', 'vantage'); ?> </label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('image'); ?> " name="<?php echo $this->get_field_name('image'); ?> " value="<?php echo esc_attr($instance['image']); ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('icon_position'); ?> "><?php _e('Icon Position', 'vantage'); ?> </label> <select id="<?php echo $this->get_field_id('icon_position'); ?> " name="<?php echo $this->get_field_name('icon_position'); ?> "> <option value="top" <?php selected('top', $instance['icon_position']); ?> ><?php esc_html_e('Top', 'vantage'); ?> </option> <option value="bottom" <?php selected('bottom', $instance['icon_position']); ?> ><?php esc_html_e('Bottom', 'vantage'); ?> </option> <option value="left" <?php selected('left', $instance['icon_position']); ?> ><?php esc_html_e('Left', 'vantage'); ?> </option> <option value="right" <?php selected('right', $instance['icon_position']); ?> ><?php esc_html_e('Right', 'vantage'); ?> </option> </select> </p> <p> <label for="<?php echo $this->get_field_id('icon_size'); ?> "><?php _e('Icon Size', 'vantage'); ?> </label> <select id="<?php echo $this->get_field_id('icon_size'); ?> " name="<?php echo $this->get_field_name('icon_size'); ?> "> <option value="small" <?php selected('small', $instance['icon_size']); ?> ><?php esc_html_e('Small', 'vantage'); ?> </option> <option value="medium" <?php selected('medium', $instance['icon_size']); ?> ><?php esc_html_e('Medium', 'vantage'); ?> </option> <option value="large" <?php selected('large', $instance['icon_size']); ?> ><?php esc_html_e('Large', 'vantage'); ?> </option> </select> </p> <p> <label for="<?php echo $this->get_field_id('more'); ?> "><?php _e('More Text', 'vantage'); ?> </label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('more'); ?> " name="<?php echo $this->get_field_name('more'); ?> " value="<?php echo esc_attr($instance['more']); ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('more_url'); ?> "><?php _e('More URL', 'vantage'); ?> </label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('more_url'); ?> " name="<?php echo $this->get_field_name('more_url'); ?> " value="<?php echo esc_attr($instance['more_url']); ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('all_linkable'); ?> "> <input type="checkbox" id="<?php echo $this->get_field_id('all_linkable'); ?> " name="<?php echo $this->get_field_name('all_linkable'); ?> " <?php checked($instance['all_linkable']); ?> /> <?php _e('Link title and icon to "More URL"', 'vantage'); ?> </label> </p> <!-- <p> <label for="<?php echo $this->get_field_id('box'); ?> "> <input type="checkbox" id="<?php echo $this->get_field_id('box'); ?> " name="<?php echo $this->get_field_name('box'); ?> " <?php checked($instance['box']); ?> /> <?php _e('Show Box Container', 'vantage'); ?> </label> </p> --> <?php }