File: /var/www/html/wp-content/plugins/hover_effects_pack/gutenberg_support.php
<?php
class HoverPackAttributes
{
static public $attributes = array(
'img' => '',
'img_id' => '',
'link' => '',
'img_title' => '',
'img_alt' => '',
'gallery_id' => '',
'disable_popup' => '',
'link_tab' => '',
'width' => '',
'height' => '',
'class' => '',
'radius' => '',
'effect' => '',
'inverse_effect' => '',
'color' => '',
'opacity' => '',
'title' => '',
'title_visible' => '',
'title_delay' => '',
'title_slide' => '',
'title_rotation' => '',
'title_scale' => '',
'title_fade' => '',
'text' => '',
'text_visible' => '',
'text_delay' => '',
'text_slide' => '',
'text_rotation' => '',
'text_scale' => '',
'text_fade' => ''
);
static public $checkboxes = array(
// 'disable_popup',
// 'link_tab'
);
static public function toBlockAttributes(){
$res = array();
foreach (self::$attributes as $attr_name => $default_value) {
$res[$attr_name] = array(
'type' => in_array($attr_name, self::$checkboxes)?
'boolean':'string'
);
}
return $res;
}
}
add_action('init', function () {
wp_register_script(
'hoverpack-effects-plugin',
plugins_url('js/hover_effects_plugin.js', __FILE__),
array('jquery'),
'1.1'
);
wp_register_script(
'hoverpack-gutenberg-script',
plugins_url('js/gutenberg_block.js', __FILE__),
array('wp-blocks', 'wp-element', 'wp-components', 'wp-editor', 'hoverpack-effects-plugin'),
'1.1'
);
register_block_type('hoverpack/block', array(
'editor_script' => 'hoverpack-gutenberg-script',
'render_callback' => function ($atts) {
return hover_pack_func($atts);
},
'attributes' => HoverPackAttributes::toBlockAttributes()
));
});