PluginProbe
Super block slider – Image/video background & content slider / trunk
Super block slider – Image/video background & content slider vtrunk
2.8.3.7 2.8.3.8 2.8.3.5 trunk 1.0 1.1 1.1.2 1.1.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.7 1.4.7 1.4.8 1.4.9 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0 2.0.1 2.1.1 All 51 releases
super-block-slider / super-block-slider.php

super-block-slider.php in Super block slider – Image/video background & content slider trunk, at super-block-slider.php

109 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Super Block Slider
4 * Description: Lightweight image/video & content slider for block and classic editor.
5 * Version: 2.8.3.8
6 * Author: mikemmx
7 * Plugin URI: https://superblockslider.com/
8 * Author URI: https://wordpress.org/support/users/mikemmx/
9 * License: GPL-2.0-or-later
10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
11 * Text Domain: super-block-slider
12 * Domain Path: /languages
13 */
14
15 // Exit if accessed directly
16 if (!defined('ABSPATH')) {
17 exit;
18 }
19
20 // Define plugin constants
21 define('SUPERBLOCKSLIDER_VERSION', '2.8.3.8');
22 define('SUPERBLOCKSLIDER_DIR', __DIR__);
23 define('SUPERBLOCKSLIDER_URL', plugin_dir_url(__FILE__));
24
25 /**
26 * Load superblockslider post type
27 */
28 $superblockslider_post_type_file = SUPERBLOCKSLIDER_DIR . '/includes/superblockslider_post_type.php';
29 if (file_exists($superblockslider_post_type_file)) {
30 require_once $superblockslider_post_type_file;
31 }
32
33 /**
34 * Register Super Block Slider
35 */
36 function superblockslider_register_block() {
37 $script_asset_path = SUPERBLOCKSLIDER_DIR . '/build/index.asset.php';
38
39 if (!file_exists($script_asset_path)) {
40 return;
41 }
42
43 $script_asset = require $script_asset_path;
44
45 // Enqueue editor scripts
46 wp_register_script(
47 'superblockslider-editor',
48 SUPERBLOCKSLIDER_URL . 'build/index.js',
49 $script_asset['dependencies'],
50 SUPERBLOCKSLIDER_VERSION
51 );
52
53 // Set translations
54 wp_set_script_translations(
55 'superblockslider-editor',
56 'super-block-slider',
57 SUPERBLOCKSLIDER_DIR . '/languages'
58 );
59
60 // Enqueue frontend scripts
61 wp_register_script(
62 'superblockslider',
63 SUPERBLOCKSLIDER_URL . 'build/superblockslider.js',
64 array(),
65 SUPERBLOCKSLIDER_VERSION,
66 true
67 );
68
69 // Enqueue styles
70 wp_register_style(
71 'superblockslider-editor',
72 SUPERBLOCKSLIDER_URL . 'build/index.css',
73 array(),
74 SUPERBLOCKSLIDER_VERSION
75 );
76
77 wp_register_style(
78 'superblockslider',
79 SUPERBLOCKSLIDER_URL . 'build/style-index.css',
80 array(),
81 SUPERBLOCKSLIDER_VERSION
82 );
83
84 // Register the block
85 register_block_type(SUPERBLOCKSLIDER_DIR);
86 }
87 add_action('init', 'superblockslider_register_block');
88
89 /**
90 * Add shortcode column
91 */
92 add_filter('manage_superblockslider_posts_columns', 'superblockslider_add_shortcode_column');
93 function superblockslider_add_shortcode_column($columns) {
94 /* translators: Column header for shortcode display in admin list */
95 $columns['post_id'] = __('Shortcode', 'super-block-slider');
96 return $columns;
97 }
98
99 /**
100 * Display shortcode in column
101 */
102 add_action('manage_superblockslider_posts_custom_column', 'superblockslider_show_shortcode', 10, 2);
103 function superblockslider_show_shortcode($column, $post_id) {
104 if ($column === 'post_id' && current_user_can('edit_posts')) {
105 /* translators: %d: slider post ID */
106 $shortcode = sprintf('[superblockslider id="%d"]', absint($post_id));
107 echo esc_html($shortcode);
108 }
109 }