post_type; if ( is_admin() && ($type == 'post' || $type == 'page') ) { array_push( $buttons, "alpha" ); } return $buttons; } //alpha_register_shortcode_button() public static function alpha_add_shortcode_plugin( $plugin_array ) { global $current_screen; $type = $current_screen->post_type; if ( is_admin() && ($type == 'post' || $type == 'page') ) { $plugin_array['alpha'] = plugin_dir_url( __FILE__ ) . '../assets/js/shortcode.js'; } return $plugin_array; } //alpha_add_shortcode_plugin() /*=========================================== Register custom post types =============================================*/ public static function alpha_post_type(){ $labels = array( 'name' => __('Testimonials', 'alpha'), 'singular_name' => __('Testimonial', 'alpha'), 'add_new' => __('Add new', 'alpha'), 'add_new_item' => __('Add new Testimonial', 'alpha'), 'edit_item' => __('Edit Testimonial', 'alpha'), 'view_item' => __('View Testimonial', 'alpha'), 'all_items' => __('All Testimonials', 'alpha'), 'search_item' => __('Search Testimonial', 'alpha'), 'not_found' => __('No Testimonial found', 'alpha'), 'not_found_in_trash' => __('No Testimonial found in trash', 'alpha'), 'parent_item_colon' => '', 'menu_name' => __('Testimonials', 'alpha') ); register_post_type( 'tf_testimonials', array( 'labels' => $labels, 'public' => true, 'has_archive' => true, 'capability_type' => 'post', 'supports' => array('thumbnail', 'title'), 'rewrite' => array( 'testimonial'), 'menu_position' => 46, 'menu_icon' => 'dashicons-format-quote', ) ); } /*============================================= Add custom metabox ==============================================*/ public static function alpha_meta_boxes(){ //testimonials meta box add_meta_box( 'tf_testimonials_cus_meta', __('Customer Testimonial', 'alpha'), array( 'Alpha_Testimonials', 'tf_testimonials_meta_fields' ), 'tf_testimonials', 'normal', 'core' ); } public static function tf_testimonials_meta_fields($post){ /** * Testimonials metabox callback function * * Adding custom fields (name, title and content) * to app_testimonials post type * * @param $post * @since 1.0 * */ $content = get_post_meta( $post->ID, 'tf_testimonial_content',true ); $name = get_post_meta( $post->ID, 'alpha_name', true ); $title = get_post_meta( $post->ID, 'alpha_title', true ); $company = get_post_meta( $post->ID, 'alpha_company', true ); $url = get_post_meta( $post->ID, 'alpha_url', true ); ?>
| true, 'media_buttons' => false, 'textarea_name' => 'tf_testimonial_content', 'textarea_rows' => 10, 'teeny' => true )); ?> |