'application/x-httpd-php', 'codemirror' => array( 'indentUnit' => 2, 'tabSize' => 2, ), ) ); $deps[] = 'code-editor'; } else { $settings = false; } $element_type = self::get_element_type(); wp_enqueue_script( 'generate-elements-metabox', plugin_dir_url( __FILE__ ) . 'assets/admin/metabox.js', $deps, GP_PREMIUM_VERSION, true ); wp_localize_script( 'generate-elements-metabox', 'elements', array( 'nonce' => wp_create_nonce( 'generate-elements-location' ), 'settings' => $settings ? wp_json_encode( $settings ) : false, 'type' => $element_type, 'custom_image' => __( 'Custom Image', 'gp-premium' ), 'fallback_image' => __( 'Fallback Image', 'gp-premium' ), 'choose' => __( 'Choose...', 'gp-premium' ), 'showID' => apply_filters( 'generate_elements_show_object_ids', false ), ) ); wp_enqueue_style( 'generate-elements-metabox', plugin_dir_url( __FILE__ ) . 'assets/admin/metabox.css', array(), GP_PREMIUM_VERSION ); wp_enqueue_style( 'generate-elements-balloon', plugin_dir_url( __FILE__ ) . 'assets/admin/balloon.css', array(), GP_PREMIUM_VERSION ); wp_enqueue_media(); wp_enqueue_script( 'wp-color-picker' ); wp_enqueue_style( 'wp-color-picker' ); wp_enqueue_script( 'wp-color-picker-alpha', plugin_dir_url( __FILE__ ) . 'assets/admin/wp-color-picker-alpha.min.js', array( 'wp-color-picker' ), GP_PREMIUM_VERSION, true ); wp_localize_script( 'wp-color-picker-alpha', 'wpColorPickerL10n', array( 'defaultLabel' => __( 'Color value', 'gp-premium' ), 'pick' => __( 'Select Color', 'gp-premium' ), 'defaultString' => __( 'Default', 'gp-premium' ), 'defaultAriaLabel' => __( 'Select default color', 'gp-premium' ), 'clear' => __( 'Clear', 'gp-premium' ), 'clearAriaLabel' => __( 'Clear color', 'gp-premium' ), ) ); if ( function_exists( 'wp_add_inline_script' ) && function_exists( 'generate_get_default_color_palettes' ) ) { // Grab our palette array and turn it into JS. $palettes = wp_json_encode( generate_get_default_color_palettes() ); // Add our custom palettes. // json_encode takes care of escaping. wp_add_inline_script( 'wp-color-picker', 'jQuery.wp.wpColorPicker.prototype.options.palettes = ' . $palettes . ';' ); } wp_enqueue_style( 'select2', GP_LIBRARY_DIRECTORY_URL . 'select2/select2.min.css', array(), '4.0.13' ); wp_enqueue_script( 'select2', GP_LIBRARY_DIRECTORY_URL . 'select2/select2.full.min.js', array( 'jquery', 'generate-elements-metabox' ), '4.0.13', true ); $css = ''; $containerWidth = function_exists( 'generate_get_option' ) ? generate_get_option( 'container_width' ) : 1100; $rightSidebarWidth = apply_filters( 'generate_right_sidebar_width', '25' ); $leftSidebarWidth = apply_filters( 'generate_left_sidebar_width', '25' ); $containerWidth = floatval( $containerWidth ); $leftSidebarWidth = '0.' . $leftSidebarWidth; $rightSidebarWidth = '0.' . $rightSidebarWidth; $leftSidebarWidth = $containerWidth - ( $containerWidth * $leftSidebarWidth ); $rightSidebarWidth = $containerWidth - ( $containerWidth * $rightSidebarWidth ); $leftSidebarWidth = $containerWidth - $leftSidebarWidth; $rightSidebarWidth = $containerWidth - $rightSidebarWidth; $css .= '.left-sidebar-block-type div:not(.block-editor-inner-blocks) > .block-editor-block-list__layout {max-width:' . $leftSidebarWidth . 'px;margin-left: auto;margin-right: auto;box-sizing: content-box;}'; $css .= '.right-sidebar-block-type div:not(.block-editor-inner-blocks) > .block-editor-block-list__layout {max-width:' . $rightSidebarWidth . 'px;margin-left: auto;margin-right: auto;box-sizing: content-box;}'; $css .= '.left-sidebar-block-type div:not(.block-editor-inner-blocks) > .block-editor-block-list__layout, .right-sidebar-block-type div:not(.block-editor-inner-blocks) > .block-editor-block-list__layout {padding: 10px;}'; $css .= 'body.left-sidebar-block-type div:not(.block-editor-inner-blocks) > .block-editor-block-list__layout .block-editor-block-list__block, body.right-sidebar-block-type div:not(.block-editor-inner-blocks) > .block-editor-block-list__layout .block-editor-block-list__block {margin-top:0;margin-bottom:0;}'; if ( function_exists( 'generate_get_option' ) && 'separate-containers' === generate_get_option( 'content_layout_setting' ) ) { $css .= 'body.left-sidebar-block-type div:not(.block-editor-inner-blocks) > .block-editor-block-list__layout, body.right-sidebar-block-type div:not(.block-editor-inner-blocks) > .block-editor-block-list__layout {background: ' . generate_get_option( 'background_color' ) . ';}'; } $css .= '.editor-styles-wrapper .wp-block:not(.editor-post-title__block), .site-header-block-type .editor-styles-wrapper .wp-block:not(.editor-post-title__block), .site-footer-block-type .editor-styles-wrapper .wp-block:not(.editor-post-title__block) {max-width: 100%;}'; wp_add_inline_style( 'generate-elements-metabox', $css ); } } } /** * Register our metabox. * * @since 1.7 */ public function register_metabox() { // Title not translated on purpose. add_meta_box( 'generate_premium_elements', 'Element', array( $this, 'element_fields' ), 'gp_elements', 'normal' ); add_meta_box( 'generate_page_hero_template_tags', __( 'Template Tags', 'gp-premium' ), array( $this, 'template_tags' ), 'gp_elements', 'side', 'low' ); remove_meta_box( 'slugdiv', 'gp_elements', 'normal' ); } /** * Output all of our metabox fields. * * @since 1.7 * * @param object $post Our post object. */ public function element_fields( $post ) { wp_nonce_field( basename( __FILE__ ), 'generate_elements_nonce' ); $type = self::get_element_type(); $merge = get_post_meta( get_the_ID(), '_generate_site_header_merge', true ); $conditions_set = get_post_meta( get_the_ID(), '_generate_element_display_conditions', true ); $post_status = get_post_status( get_the_ID() ); ?>
/> | |
/> | |
/> | |
DISALLOW_FILE_EDIT' ); ?> /> | |
? | |
/> | |
|
|
>
>
%s',
sprintf(
/* translators: Upload Custom Image or Fallback image */
esc_html__( 'Upload %s', 'gp-premium' ),
'' . esc_html( $image_text ) . ''
)
);
?>
|
|
/> | |
? | /> |
? | /> |
? | |
? |
px
|
';
}
?>
/>
|
|
';
}
?>
/>
|
|
';
}
?>
/>
|
|
';
}
?>
/>
|
|
/> | |
|
|
/> | |
/> | |
/> | |
/> | |
/> | |
/> | |
/> | |
/> |