/** * Fields key * * @package Post Type Slider for Customizr * @since 0.1 * @param $post_id Post ID * @return string Metabox fields */ public function metadata($post_id) { global $post_type; $options = get_option('risbl_slider_customizr_settings'); $selected_cpt = $options["post_type"]; $is_enabled = risbl_prefix_is_enabled(); if (!$is_enabled) { return; } if ($post_type != $selected_cpt) { return; } $fields = $this->metadate_field_keys(); // Option enabled $risbl_set_as_slider_item_id = $fields['set_as_slider']; $risbl_set_as_slider_item_value = get_post_meta($post_id, $risbl_set_as_slider_item_id, true); // Option enabled ends $title_id = $fields['title_id']; $title_value = get_post_meta($post_id, $title_id, true); $text_id = $fields['text_id']; $text_value = get_post_meta($post_id, $text_id, true); $color_id = $fields['color_id']; $color_value = get_post_meta($post_id, $color_id, true); $button_id = $fields['button_id']; $button_value = get_post_meta($post_id, $button_id, true); $link_id = $fields['link_id']; $link_value = get_post_meta($post_id, $link_id, true); $tc_all_posts = array(); /// ?????? $custom_link_id = $fields['custom_link_id']; $custom_link_value = get_post_meta($post_id, $custom_link_id, true); $link_target_id = $fields['link_target_id']; $link_target_value = get_post_meta($post_id, $link_target_id, true); $link_whole_slide_id = $fields['link_whole_slide_id']; $link_whole_slide_value = get_post_meta($post_id, $link_whole_slide_id, true); ?> <div class="risbl-metabox"> <hr /> <h3><?php _e('Set as slider item?', 'risbl-cpt-slider-customizr'); ?> </h3> <input name="<?php echo $risbl_set_as_slider_item_id; ?> " id="<?php echo $risbl_set_as_slider_item_id; ?> " type="checkbox" class="iphonecheck" value="1" <?php checked($risbl_set_as_slider_item_value, $current = true, $echo = true); ?> /> <?php $css = ''; if ($risbl_set_as_slider_item_value == 1) { $css = 'style="display: block;"'; } ?> <div class="risbl-metabox-slider-fields" <?php echo $css; ?> > <div class="meta-box-item-title"> <h4><?php _e('Title text (80 char. max length)', 'risbl-cpt-slider-customizr'); ?> </h4> </div> <div class="meta-box-item-content"> <input class="widefat" name="<?php echo esc_attr($title_id); ?> " id="<?php echo esc_attr($title_id); ?> " value="<?php echo esc_attr($title_value); ?> " style="width:50%"> </div> <div class="meta-box-item-title"> <h4><?php _e('Description text (below the title, 250 char. max length)', 'risbl-cpt-slider-customizr'); ?> </h4> </div> <div class="meta-box-item-content"> <textarea name="<?php echo esc_attr($text_id); ?> " id="<?php echo esc_attr($text_id); ?> " style="width:50%"><?php echo esc_attr($text_value); ?> </textarea> </div> <div class="meta-box-item-title"> <h4><?php _e("Title and text color", 'risbl-cpt-slider-customizr'); ?> </h4> </div> <div class="meta-box-item-content"> <input id="<?php echo esc_attr($color_id); ?> " name="<?php echo esc_attr($color_id); ?> " value="<?php echo esc_attr($color_value); ?> "/> <div id="colorpicker"></div> </div> <div class="meta-box-item-title"> <h4><?php _e('Button text (80 char. max length)', 'risbl-cpt-slider-customizr'); ?> </h4> </div> <div class="meta-box-item-content"> <input class="widefat" name="<?php echo esc_attr($button_id); ?> " id="<?php echo esc_attr($button_id); ?> " value="<?php echo esc_attr($button_value); ?> " style="width:50%"> </div> <div class="meta-box-item-title"> <h4><?php _e("Choose a linked page or post (among the last 100).", 'risbl-cpt-slider-customizr'); ?> </h4> </div> <div class="meta-box-item-content"> <select name="<?php echo esc_attr($link_id); ?> " id="<?php echo esc_attr($link_id); ?> "> <?php //no link option ?> <option value="" <?php selected($link_value, $current = null, $echo = true); ?> > <?php _e('No link', 'risbl-cpt-slider-customizr'); ?> </option> <?php foreach ($tc_all_posts as $type) { ?> <?php foreach ($type as $key => $item) { ?> <option value="<?php echo esc_attr($item->ID); ?> " <?php selected($link_value, $current = $item->ID, $echo = true); ?> >{<?php echo esc_attr($item->post_type); ?> } <?php echo esc_attr($item->post_title); ?> </option> <?php } ?> <?php } ?> </select><br /> </div> <div class="meta-box-item-title"> <h4><?php _e("or a custom link (leave this empty if you already selected a page or post above)", 'risbl-cpt-slider-customizr'); ?> </h4> </div> <div class="meta-box-item-content"> <input class="widefat" name="<?php echo $custom_link_id; ?> " id="<?php echo $custom_link_id; ?> " value="<?php echo $custom_link_value; ?> " style="width:50%"> </div> <div class="meta-box-item-title"> <h4><?php _e("Open link in a new page/tab", 'risbl-cpt-slider-customizr'); ?> </h4> </div> <div class="meta-box-item-content"> <input name="<?php echo $link_target_id; ?> " type="hidden" value="0"/> <input name="<?php echo $link_target_id; ?> " id="<?php echo $link_target_id; ?> " type="checkbox" class="iphonecheck" value="1" <?php checked($link_target_value, $current = true, $echo = true); ?> /> </div> <div class="meta-box-item-title"> <h4><?php _e("Link the whole slide", 'risbl-cpt-slider-customizr'); ?> </h4> </div> <div class="meta-box-item-content"> <input name="<?php echo $link_whole_slide_id; ?> " type="hidden" value="0"/> <input name="<?php echo $link_whole_slide_id; ?> " id="<?php echo $link_whole_slide_id; ?> " type="checkbox" class="iphonecheck" value="1" <?php checked($link_whole_slide_value, $current = true, $echo = true); ?> /> </div> </div><!-- /.risbl-metabox-slider-fields --> </div><!-- /.risbl-metabox --> <?php }
function risbl_prefix_is_enabled() { $options = get_option('risbl_slider_customizr_settings'); if (isset($options["enable"]) && $options["enable"] == '1') { return true; } else { return false; } } /** * Stop here if plugin dasabled * * @since 1.0.0 * @return bool */ $is_enabled = risbl_prefix_is_enabled(); if (!$is_enabled) { return; } add_filter('tc_show_slider_edit_link', 'risbl_prefix_remove_edit_slider_link'); if (!function_exists('risbl_prefix_remove_edit_slider_link')) { /** * Remove the existing slider query. * * @since 0.1 * @return bool */ function risbl_prefix_remove_edit_slider_link() { return false; }