array( $this, 'render_modula_gallery' ), 'editor_script' => 'modula-link-gutenberg', 'editor_style' => 'modula-link-gutenberg', ) ); } public function generate_js_vars() { wp_localize_script( 'modula-link-gutenberg', 'modulaLinkVars', apply_filters('modula_link_gutenberg_vars', array( 'adminURL' => admin_url(), 'ajaxURL' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'modula_nonce' ), 'gutenbergLinkTitle' => esc_html__( 'Modula Link', 'modula-pro') ) ) ); } public function render_modula_gallery( $atts ) { if ( !isset( $atts['id'] ) ) { return; } if ( !isset( $atts['align'] ) ) { $atts['align'] = ''; } $font_size = isset( $atts['fontSize'] ) ? 'font-size:' . absint( $atts['fontSize'] ) . 'px;' : ''; $background = isset( $atts['buttonBackgroundColor']['hex'] ) ? 'background:' . sanitize_hex_color( $atts['buttonBackgroundColor']['hex'] ) . ';' : ''; $color = isset( $atts['buttonTextColor']['hex'] ) ? 'color: ' . sanitize_hex_color( $atts['buttonTextColor']['hex'] ) . ';' : ''; $border_width = isset( $atts['borderWidth'] ) ? absint( $atts['borderWidth'] ) . 'px' : ''; $border_type = isset( $atts['borderType'] ) ? esc_html( $atts['borderType'] ) : ''; $border_color = isset( $atts['borderColor']['hex'] ) ? sanitize_hex_color( $atts['borderColor']['hex'] ) : ''; $border_radius = isset( $atts['borderRadius'] ) ? absint( $atts['borderRadius'] ) . '%' : ''; $text_align = isset( $atts['textAlignment'] ) ? 'text-align: ' . esc_html( $atts['textAlignment'] ) . ';' : ''; $text_color = isset( $atts['buttonHoverTextColor']['hex'] ) ? 'color: ' . sanitize_hex_color( $atts['buttonHoverTextColor']['hex'] ) . ';' : ''; $btn_hover_bcg = isset( $atts['buttonHoverBackgroundColor']['hex'] ) ? 'background: ' . sanitize_hex_color( $atts['buttonHoverBackgroundColor']['hex'] ) . ';' : ''; $html = ''; return $html . '[modula-link id=' . absint( $atts['id'] ) . ' align=' . esc_attr( $atts['align'] ) . ']' . wp_kses_post( (isset($atts['buttonText'])) ? $atts['buttonText'] : __('Enter your message here','modula-pro')) . '[/modula-link]'; } } new Modula_Pro_Gutenberg();