Plugin Directory

Changeset 2243966


Ignore:
Timestamp:
02/13/2020 03:43:53 PM (6 years ago)
Author:
magadanski_uchen
Message:

Register basic Gutenberg Block

Location:
magadanski-similar-posts/trunk
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • magadanski-similar-posts/trunk/magadanski-similar-posts.php

    r1493815 r2243966  
    44 * Plugin URI: http://wordpress.org/plugins/magadanski-similar-posts/
    55 * Description: Shows similar posts ordered by the number of common categories.
    6  * Version: 1.2.4
     6 * Version: 1.3
    77 * Author: Georgi Popov a.k.a. Magadanski_Uchen
    88 * Author URI: http://magadanski.com/
     
    3030     * @const VERSION
    3131     */
    32     const VERSION = '1.2.4';
     32    const VERSION = '1.3';
    3333   
    3434    /**
     
    142142       
    143143        $this->vc_integration();
     144        $this->gutenberg_integration();
    144145    }
    145146   
     
    164165    public function admin_enqueue_scripts() {
    165166        wp_enqueue_style('msp-admin', $this->plugin_url() . 'admin.css', array(), self::VERSION, 'all');
     167        wp_enqueue_style('msp-block', $this->plugin_url() . 'blocks/edit.css', array(), self::VERSION, 'all');
    166168    }
    167169   
     
    420422        }
    421423    }
     424   
     425    /**
     426     * Gutenberg Integration
     427     *
     428     * Register a Gutenberg Block for WordPress 5+
     429     *
     430     * @since 1.3
     431     * @access public
     432     * @return void
     433     */
     434    public function gutenberg_integration() {
     435        if (function_exists('register_block_type')) {
     436            $script_dependencies = array(
     437                'wp-blocks',
     438                'wp-element',
     439                'wp-server-side-render'
     440            );
     441           
     442            wp_register_script('msp-block', $this->plugin_url() . 'blocks/index.js', $script_dependencies, self::VERSION);
     443           
     444            $block_options = array(
     445                'render_callback' => array(&$this, 'shortcode'),
     446                'editor_script' => 'msp-block'
     447            );
     448           
     449            register_block_type(__('Similar Posts', 'magadanski-similar-posts'), $block_options);
     450        }
     451    }
    422452}
    423453
Note: See TracChangeset for help on using the changeset viewer.