_x( 'Shortcoder', 'Post Type General Name', 'shortcoder' ), 'singular_name' => _x( 'Shortcode', 'Post Type Singular Name', 'shortcoder' ), 'menu_name' => __( 'Shortcoder', 'shortcoder' ), 'name_admin_bar' => __( 'Shortcode', 'shortcoder' ), 'archives' => __( 'Shortcode Archives', 'shortcoder' ), 'attributes' => __( 'Shortcode Attributes', 'shortcoder' ), 'parent_item_colon' => __( 'Parent Shortcode:', 'shortcoder' ), 'all_items' => __( 'All Shortcodes', 'shortcoder' ), 'add_new_item' => __( 'Create shortcode', 'shortcoder' ), 'add_new' => __( 'Create shortcode', 'shortcoder' ), 'new_item' => __( 'New Shortcode', 'shortcoder' ), 'edit_item' => __( 'Edit Shortcode', 'shortcoder' ), 'update_item' => __( 'Update Shortcode', 'shortcoder' ), 'view_item' => __( 'View Shortcode', 'shortcoder' ), 'view_items' => __( 'View Shortcodes', 'shortcoder' ), 'search_items' => __( 'Search Shortcode', 'shortcoder' ), 'not_found' => __( 'Not found', 'shortcoder' ), 'not_found_in_trash' => __( 'Not found in Trash', 'shortcoder' ), 'featured_image' => __( 'Featured Image', 'shortcoder' ), 'set_featured_image' => __( 'Set featured image', 'shortcoder' ), 'remove_featured_image' => __( 'Remove featured image', 'shortcoder' ), 'use_featured_image' => __( 'Use as featured image', 'shortcoder' ), 'insert_into_item' => __( 'Insert into shortcode', 'shortcoder' ), 'uploaded_to_this_item' => __( 'Uploaded to this shortcode', 'shortcoder' ), 'items_list' => __( 'Shortcodes list', 'shortcoder' ), 'items_list_navigation' => __( 'Shortcodes list navigation', 'shortcoder' ), 'filter_items_list' => __( 'Filter shortcodes list', 'shortcoder' ), ); $args = apply_filters( 'sc_mod_post_type_args', array( 'label' => __( 'Shortcode', 'shortcoder' ), 'labels' => $labels, 'supports' => false, 'taxonomies' => array( 'sc_tag' ), 'hierarchical' => false, 'public' => false, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 25, 'menu_icon' => '', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => true, 'publicly_queryable' => false, 'show_in_rest' => false, 'map_meta_cap' => true, 'capability_type' => 'shortcoder', )); register_post_type( SC_POST_TYPE, $args ); } public static function register_taxonomy(){ $labels = array( 'name' => _x( 'Tags', 'Taxonomy General Name', 'shortcoder' ), 'singular_name' => _x( 'Tag', 'Taxonomy Singular Name', 'shortcoder' ), 'menu_name' => __( 'Tags', 'shortcoder' ), 'all_items' => __( 'All Tags', 'shortcoder' ), 'parent_item' => __( 'Parent Tag', 'shortcoder' ), 'parent_item_colon' => __( 'Parent Tag:', 'shortcoder' ), 'new_item_name' => __( 'New Tag Name', 'shortcoder' ), 'add_new_item' => __( 'Add New Tag', 'shortcoder' ), 'edit_item' => __( 'Edit Tag', 'shortcoder' ), 'update_item' => __( 'Update Tag', 'shortcoder' ), 'view_item' => __( 'View Tag', 'shortcoder' ), 'separate_items_with_commas' => __( 'Separate tags with commas', 'shortcoder' ), 'add_or_remove_items' => __( 'Add or remove tags', 'shortcoder' ), 'choose_from_most_used' => __( 'Choose from the most used', 'shortcoder' ), 'popular_items' => __( 'Popular Tags', 'shortcoder' ), 'search_items' => __( 'Search Tags', 'shortcoder' ), 'not_found' => __( 'Not Found', 'shortcoder' ), 'no_terms' => __( 'No tags', 'shortcoder' ), 'items_list' => __( 'Tags list', 'shortcoder' ), 'items_list_navigation' => __( 'Tags list navigation', 'shortcoder' ), ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'public' => false, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => false, 'show_tagcloud' => false, 'show_in_rest' => false, ); register_taxonomy( 'sc_tag', array( SC_POST_TYPE ), $args ); } public static function is_sc_admin_page(){ $screen = get_current_screen(); if( $screen && $screen->post_type == SC_POST_TYPE ){ return true; }else{ return false; } } public static function is_edit_page( $new_edit = null ){ global $pagenow; if (!is_admin()) return false; if( $new_edit == 'edit' ){ return in_array( $pagenow, array( 'post.php' ) ); }elseif( $new_edit == 'new' ){ return in_array( $pagenow, array( 'post-new.php' ) ); }else{ return in_array( $pagenow, array( 'post.php', 'post-new.php' ) ); } } public static function inline_js_variables(){ return array( 'sc_version' => SC_VERSION, 'ajax_url' => get_admin_url() . 'admin-ajax.php', 'screen' => get_current_screen(), 'nonce' => wp_create_nonce( 'shortcoder_nonce' ), 'text_editor_switch_notice' => __( 'Switching editor will refresh the page. Please save your changes before refreshing. Do you want to refresh the page now ?', 'shortcoder' ) ); } public static function enqueue_scripts( $hook ){ wp_enqueue_style( 'sc-icon-css', SC_ADMIN_URL . 'css/menu-icon.css', array(), SC_VERSION ); if( !self::is_sc_admin_page() || $hook == 'shortcoder_page_settings' ){ return false; } wp_enqueue_style( 'sc-admin-css', SC_ADMIN_URL . 'css/style.css', array(), SC_VERSION ); wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'sc-admin-js', SC_ADMIN_URL . 'js/script.js', array( 'jquery' ), SC_VERSION ); wp_localize_script( 'sc-admin-js', 'SC_VARS', self::inline_js_variables() ); } public static function admin_ajax(){ check_admin_referer( 'shortcoder_nonce' ); if( !current_user_can( 'edit_shortcoders' ) ){ wp_die(); } $g = self::clean_get(); $do = $g[ 'do' ]; if( $do == 'close_changelog' ){ update_option( 'shortcoder_last_changelog', SC_VERSION ); echo 'done'; } wp_die(); } public static function changelog(){ if( !self::is_sc_admin_page() ){ return false; } $last_changelog = get_option( 'shortcoder_last_changelog' ); if( $last_changelog && version_compare( $last_changelog, SC_VERSION, '>=' ) ){ return false; } $response = wp_remote_get( 'https://raw.githubusercontent.com/vaakash/vaakash.github.io/master/misc/shortcoder/changelogs/' . SC_VERSION . '.html' ); $changelog = false; if( !is_wp_error( $response ) && $response[ 'response' ][ 'code' ] == 200 ){ $changelog = wp_remote_retrieve_body( $response ); } if( !$changelog ){ update_option( 'shortcoder_last_changelog', SC_VERSION ); return false; } echo '
' . wp_kses( __( 'WordPress has a native exporter tool which can be used to export shortcoder data. Navigate to Tools -> Export
and select "Shortcoder" as the content to export.', 'shortcoder' ), array( 'code' => array() ) ) . '
' . wp_kses( __( 'The XML file downloaded through the native export process can be imported via WordPress\'s own import tool. Navigate to Tools -> Import
, install the importer plugin if not installed and run the importer under WordPress section.', 'shortcoder' ), array( 'code' => array() ) ) . '
' . esc_html__( 'To import from other sources like CSV, excel please read the below linked documentation.', 'shortcoder' ) . '
' . esc_html__( 'Open documentation', 'shortcoder' ) . '