*/ class Scrollsequence_Admin { /** * The ID of this plugin. * * @since 0.7.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name ; /** * The version of this plugin. * * @since 0.7.0 * @access private * @var string $version The current version of this plugin. */ private $version ; /** * Initialize the class and set its properties. * * @since 0.7.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the admin area. * * @since 0.7.0 */ public function enqueue_styles() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Scrollsequence_Loader as all of the hooks are defined * in that particular class. * * The Scrollsequence_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ // Ak: I want to add an IF statement to enqueue scripts only to my CPT global $post_type ; if ( 'scrollsequence' == $post_type ) { wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/scrollsequence-admin.css', array(), $this->version, 'all' ); } // Ak: end } /** * Register the JavaScript for the admin area. * * @since 0.7.0 */ public function enqueue_scripts() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Scrollsequence_Loader as all of the hooks are defined * in that particular class. * * The Scrollsequence_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ // Ak: I want to add an IF statement to enqueue scripts only to my CPT global $post_type ; global $pagenow ; if ( 'scrollsequence' == $post_type && ('post-new.php' === $pagenow || 'post.php' === $pagenow) ) { // Free wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/scrollsequence-admin.js', array( 'jquery' ), $this->version, true ); } // Ak: end } /** * Register Scrollsequence CPT . * * @since 0.7.0 */ public function scrollsequence_cpt() { require_once "create-cpt.php"; } /** * Register Scrollsequence CPT . * * @since 0.7.3 */ public function scrollsequence_cpt_submenu() { add_submenu_page( 'edit.php?post_type=scrollsequence', /*parent_slug*/ 'Dashboard Scrollsequence', /*page title*/ 'Dashboard', /*menu title*/ 'edit_posts', /*roles and capability needed*/ // Update 0.9.93 'dashboard', /*menu slug*/ 'scrollsequence_cpt_dashboard_callback' ); function scrollsequence_cpt_dashboard_callback() { //include_once 'dashboard.php'; - results on parse error require_once "partials/scrollsequence-admin-display.php"; } } /** * Single file custom template for scrollsequence. I am following this: * https://code.tutsplus.com/tutorials/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes--wp-27645 * ref "tutsplus" in class-scrollsequence add action thing * @since 0.7.0 * @uses i dont know * Step 1 https://blog.wplauncher.com/add-meta-box-wordpress-custom-post-type/ */ public function scrollsequence_template( $template_path ) { if ( get_post_type() == 'scrollsequence' ) { if ( is_single() ) { // checks if the file exists in the theme first, // otherwise serve the file from the plugin if ( $theme_file = locate_template( array( 'single-scrollsequence.php' ) ) ) { $template_path = $theme_file; } else { $template_path = plugin_dir_path( __DIR__ ) . 'public/partials/single-scrollsequence.php'; } } } return $template_path; } /** * Carbon Fields Boot function. This function boots up carbon fields. * * @since 0.9.8 */ public function scrollsequence_carbon_fields_load() { require_once __DIR__ . '/../includes/carbonfields/autoload.php'; \Carbon_Fields\Carbon_Fields::boot(); } public function scrollsequence_carbon_fields() { $scrollsequence_advert_html = '
More Scale and Alignment settings are available in Scrollsequence PRO.
NEW: We offer 14 days FREE trial - no card required, no risk.
'; // FREE VERSION Container::make( 'post_meta', 'Scrollsequence' )->where( 'post_type', '=', 'scrollsequence' )->set_context( 'carbon_fields_after_title' )->add_fields( array( Field::make( 'complex', 'scrollsequence_page', 'Page' )->setup_labels( array( 'plural_name' => 'Pages', 'singular_name' => 'Page', ) )->set_layout( 'tabbed-horizontal' )->set_required( true )->set_max( 3 )->add_fields( array( Field::make( 'rich_text', 'scrollsequence_p_wysiwyg', __( 'Page Content' ) )->set_default_value( 'Panorama (Mobile)
' ), Field::make( 'select', 'scrollsequence_p_scaleto_mobile', __( 'Panorama (Mobile)' ) )->set_width( 30 )->set_options( array( 'fill' => ' Scale to fill', 'fit' => 'Scale to fit 100%', '0.5' => 'Scale to fit 50%', ) ), Field::make( 'text', 'scrollsequence_p_alignx_mobile', 'Horizontal Align' )->set_help_text( $scrollsequence_left_center_right )->set_width( 35 )->set_attribute( 'type', 'range' )->set_classes( 'ssq-range-slider' )->set_default_value( '0.5' )->set_attribute( 'min', '0' )->set_attribute( 'max', '1' )->set_attribute( 'step', '0.5' ), // ROADM Field::make( 'text', 'scrollsequence_p_aligny_mobile', 'Vertical Align' )->set_help_text( $scrollsequence_bottom_center_top )->set_width( 35 )->set_attribute( 'type', 'range' )->set_classes( 'ssq-range-slider' )->set_default_value( '0.5' )->set_attribute( 'min', '0' )->set_attribute( 'max', '1' )->set_attribute( 'step', '0.5' ), // ROADM // LANDSCAPE (DEKSTOP) Field::make( 'html', 'scrollsequence_info_html_landscape' )->set_html( 'Landscape (Desktop)
' ), Field::make( 'select', 'scrollsequence_p_scaleto_desktop', __( 'Scale' ) )->set_width( 30 )->set_options( array( 'fill' => ' Scale to fill', 'fit' => 'Scale to fit 100%', '0.5' => 'Scale to fit 50%', ) ), Field::make( 'text', 'scrollsequence_p_alignx_desktop', 'Horizontal Align' )->set_help_text( $scrollsequence_left_center_right )->set_width( 35 )->set_attribute( 'type', 'range' )->set_classes( 'ssq-range-slider' )->set_default_value( '0.5' )->set_attribute( 'min', '0' )->set_attribute( 'max', '1' )->set_attribute( 'step', '0.5' ), // ROADM Field::make( 'text', 'scrollsequence_p_aligny_desktop', 'Vertical Align' )->set_help_text( $scrollsequence_bottom_center_top )->set_width( 35 )->set_attribute( 'type', 'range' )->set_classes( 'ssq-range-slider' )->set_default_value( '0.5' )->set_attribute( 'min', '0' )->set_attribute( 'max', '1' )->set_attribute( 'step', '0.5' ), // ROADM Field::make( 'html', 'scrollsequence_info_html_freealignadv' )->set_html( $scrollsequence_aglignmentadv ), ) )->set_header_template( '<%- $_index %>' ) ) ); // End of ELSE (FREE) /* * SIDE CONTEXT - SETTINGS */ Container::make( 'post_meta', 'Settings' )->where( 'post_type', '=', 'scrollsequence' )->set_context( 'side' )->set_priority( 'low' )->add_fields( array( Field::make( 'text', 'scrollsequence_image_opacity', __( 'Image Opacity' ) )->set_attribute( 'type', 'number' )->set_required( true )->set_default_value( '1' )->set_attribute( 'min', '0' )->set_attribute( 'max', '1' )->set_attribute( 'step', '0.01' ), Field::make( 'select', 'scrollsequence_content_spacer', 'Classic Content Position' )->add_options( array( 'after100' => 'End of Document (default)', 'after' => 'End of Document (with overlap) ', 'during' => 'Start of Document', ) ), Field::make( 'color', 'scrollsequence_bodybgcolor', __( 'Body Background Color' ) )->help_text( 'Set CSS attribute background-color of body.single-scrollsequence class.' ), Field::make( 'color', 'scrollsequence_classic_content_after_bgcolor', __( 'Background Color - After Scrollsequence' ) )->help_text( 'Use in case you want to have different background color after the scrollsequence is finished. Only active when there is content after the image sequence. ' ), Field::make( 'textarea', 'scrollsequence_custom_css', __( 'Custom CSS' ) )->help_text( 'Enter custom CSS here.' ) ) ); /* * SIDE CONTEXT - ADVANCED SETTINGS */ Container::make( 'post_meta', 'Advanced Settings' )->where( 'post_type', '=', 'scrollsequence' )->set_context( 'side' )->set_priority( 'low' )->add_fields( array( Field::make( 'checkbox', 'scrollsequence_show_sidebar', __( 'Show Sidebar' ) )->set_option_value( 'yes' )->help_text( 'Experimental, take care' ), Field::make( 'checkbox', 'scrollsequence_show_footer', __( 'Show Footer' ) )->set_option_value( 'yes' )->help_text( 'Experimental, take care.