suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'WP_DEBUG' ) && WP_DEBUG ? '' : '.min'; $this->plugin_name = $plugin_name; $this->version = $version; // Autoload system. spl_autoload_register( array( $this, 'autoload' ) ); // Register options. add_action( 'after_setup_theme', array( $this, 'register_options' ) ); // Plugin action link Button. add_filter( 'plugin_action_links', array( $this, 'add_plugin_action_links' ), 10, 2 ); } /** * Registers various options and settings for the post carousel plugin. * * This function sets up metaboxes for preview, layout, options, and shortcodes. * It also initializes settings, layout replacement, and tools for the plugin. * * @since 2.2.0 */ public function register_options() { SPS_Metaboxes::preview_metabox( 'sp_pcp_display' ); SPS_Metaboxes::layout_metabox( 'sp_pcp_layouts' ); SPS_Metaboxes::option_metabox( 'sp_pcp_view_options' ); SPS_Metaboxes::shortcode_metabox( 'sp_pcp_display_shortcode' ); SPS_Metaboxes::page_builders_metabox( 'sp_pcp_page_builder_notice' ); SPS_Metaboxes::promotional_metabox( 'sp_pcp_promotional_notice' ); SPS_Settings::settings( 'sp_post_carousel_settings' ); SPS_ReplaceLayout::Replace_Layout( 'sp_post_carousel_rpl' ); // SPS_Tools::tools( 'sp_post_carousel_tools' ); } /** * Add plugin action menu * * @param array $links The action link. * @param array $file The file link. * * @return array */ public function add_plugin_action_links( $links, $file ) { if ( SMART_POST_SHOW_BASENAME === $file ) { $new_links = array( sprintf( '%s', admin_url( 'post-new.php?post_type=sp_post_template&spblock_inserter=true' ), __( 'Add Post Layout', 'post-carousel' ) ), ); $links['go_pro'] = sprintf( '%s', 'https://wpsmartpost.com/', 'color:#1dab87;font-weight:bold', __( 'Go Pro!', 'post-carousel' ) ); return array_merge( $new_links, $links ); } return $links; } /** * Add plugin row meta link * * @param [array] $plugin_meta Add plugin row meta link. * @param [url] $file plugin row meta link. * @return array */ public function after_pcp_row_meta( $plugin_meta, $file ) { if ( SMART_POST_SHOW_BASENAME == $file ) { $plugin_meta[] = '' . __( 'Ready Patterns', 'post-carousel' ) . ''; $plugin_meta[] = '' . __( 'Docs', 'post-carousel' ) . ''; $plugin_meta[] = '' . __( 'Video Tutorials', 'post-carousel' ) . ''; } return $plugin_meta; } /** * Autoload class files on demand * * @param string $class requested class name. * @since 2.2.0 */ private function autoload( $class ) { $name = explode( '_', $class ); if ( isset( $name[1] ) ) { $class_name = strtolower( $name[1] ); $pcp_config_paths = array( 'views/', 'views/configs/settings/', 'views/configs/generator/', 'help-page/' ); foreach ( $pcp_config_paths as $sp_ppc_path ) { $filename = plugin_dir_path( __FILE__ ) . '/' . $sp_ppc_path . 'class-sps-' . $class_name . '.php'; if ( file_exists( $filename ) ) { require_once $filename; } } } } /** * Register the stylesheets for the admin area. * * @since 2.2.0 */ public function enqueue_styles() { $current_screen = get_current_screen(); $the_current_post_type = $current_screen->post_type; $pcp_page_base = 'sp_post_carousel_page_pcp_settings' === $current_screen->base || 'sp_post_carousel_page_pcp_tools' === $current_screen->base || 'sp_post_carousel_page_pcp_replace_layout' === $current_screen->base || 'sp_post_carousel_page_pcp_help' === $current_screen->base; if ( 'sp_post_carousel' === $the_current_post_type || $pcp_page_base ) { wp_enqueue_style( 'font-awesome' ); wp_enqueue_style( 'pcp_swiper' ); wp_enqueue_style( 'pcp_fonttello_icon' ); wp_enqueue_style( 'pcp-style' ); } wp_enqueue_style( 'sp-' . SP_PC_PLUGIN_NAME, SP_PC_URL . 'admin/assets/css/post-carousel-admin.min.css', array(), SP_PC_VERSION, 'all' ); } /** * Register the JavaScript for the admin area. * * @since 2.2.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 Smart_Post_Show_Loader as all of the hooks are defined * in that particular class. * * The Smart_Post_Show_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ $current_screen = get_current_screen(); $the_current_post_type = $current_screen->post_type; if ( 'sp_post_carousel' === $the_current_post_type ) { wp_enqueue_script( SP_PC_PLUGIN_NAME, SP_PC_URL . 'admin/assets/js/post-carousel-admin.min.js', array( 'jquery' ), SP_PC_VERSION, true ); wp_enqueue_script( 'pcp_swiper' ); wp_enqueue_script( 'pcp_script' ); // Fix the plugin ui interaction conflict along with EasyTimeTable plugin. wp_dequeue_script( 'jQuery-ui' ); } } /** * Add carousel admin columns. * * @since 2.2.0 * @return statement */ public function filter_carousel_admin_column() { $admin_columns['cb'] = ''; $admin_columns['title'] = __( 'Title', 'post-carousel' ); $admin_columns['shortcode'] = __( 'Shortcode', 'post-carousel' ); $admin_columns['pcp_layout'] = __( 'Layout', 'post-carousel' ); $admin_columns['date'] = __( 'Date', 'post-carousel' ); return $admin_columns; } /** * Display admin columns for the carousels. * * @param mix $column The columns. * @param string $post_id The post ID. * @return void */ public function display_carousel_admin_fields( $column, $post_id ) { $pcp_layouts = get_post_meta( $post_id, 'sp_pcp_layouts', true ); $carousels_types = isset( $pcp_layouts['pcp_layout_preset'] ) ? $pcp_layouts['pcp_layout_preset'] : ''; switch ( $column ) { case 'shortcode': ?>
id, array( 'plugins', 'plugins-network' ), true ); } /** * Bottom review notice. * * @param string $text The review notice. * @return string */ public function sp_spc_footer_text( $text ) { $screen = get_current_screen(); if ( 'sp_post_carousel_page_pcp_help' === $screen->id || 'sp_post_carousel' === $screen->post_type || 'toplevel_page_sp_post_carousel_settings' === $screen->id ) { $heart_icon = ' '; $social_icons = array( 'linkedin' => array( 'url' => 'https://www.linkedin.com/company/shapedplugin', 'icon' => '', ), 'twitter' => array( 'url' => 'https://www.x.com/shapedplugin/', 'icon' => '', ), 'wordpress' => array( 'url' => 'https://profiles.wordpress.org/shapedplugin/#content-plugins', 'icon' => '', ), 'facebook' => array( 'url' => 'https://www.facebook.com/shapedplugin/', 'icon' => '', ), 'youtube' => array( 'url' => 'https://www.youtube.com/@shapedplugin', 'icon' => '', ), ); $social_html = ''; foreach ( $social_icons as $platform => $data ) { $social_html .= sprintf( '%s', esc_url( $data['url'] ), esc_attr( ucfirst( $platform ) ), $data['icon'] ); } $text = sprintf( '', esc_html__( 'Made with', 'post-carousel' ), $heart_icon, esc_html__( 'by the', 'post-carousel' ), $social_html ); } return $text; } /** * Bottom version notice. * * @param string $text The version notice. * @return string */ public function sp_spc_version_text( $text ) { $screen = get_current_screen(); if ( 'sp_post_carousel_page_pcp_help' === $screen->id || 'sp_post_carousel' === $screen->post_type || 'toplevel_page_sp_post_carousel_settings' === $screen->id ) { $text = sprintf( 'Enjoyed Smart Post? Rate us! ★★★★★ ' ); } return $text; } } /** * Smart Post Show dashboard capability. * * @return string */ function sp_pc_dashboard_capability() { return apply_filters( 'sp_pc_dashboard_capability', 'manage_options' ); }