__( 'SR Anywhere', 'sr-anywhere' ), 'base' => self::TAG, 'description' => __( 'A module or page from SR Anywhere', 'sr-anywhere' ), 'category' => __( 'Content', 'sr-anywhere' ), 'icon' => SRANYWHERE_URL . 'assets/sr-mark.svg', 'show_settings_on_create' => true, 'params' => array( array( 'type' => 'dropdown', 'heading' => __( 'Module', 'sr-anywhere' ), 'param_name' => 'key', 'value' => self::options(), 'admin_label' => true, 'save_always' => true, 'description' => __( 'Published modules only. Make, edit and publish them in SR Anywhere.', 'sr-anywhere' ), ), array( 'type' => 'dropdown', 'heading' => __( 'Width', 'sr-anywhere' ), 'param_name' => 'align', 'value' => array( __( 'Full width', 'sr-anywhere' ) => 'full', __( 'The column\'s width', 'sr-anywhere' ) => '', ), 'std' => 'full', 'save_always' => true, ), array( 'type' => 'textfield', 'heading' => __( 'Leave room for (full screen)', 'sr-anywhere' ), 'param_name' => 'offset', 'description' => __( 'The CSS selector of the site\'s header, for full-screen modules whose header does not lie over them. The admin bar is left out by itself.', 'sr-anywhere' ), ), ), ); } /** * The select's choices, WPBakery's way: label => key. Labels stay unique, as WPBakery keys them by label. * * @return array */ private static function options() { $options = array( __( '— Pick a module —', 'sr-anywhere' ) => '' ); foreach ( Picker::items() as $item ) { $label = Picker::label( $item ); if ( isset( $options[ $label ] ) ) { $label .= ' · ' . $item['embedKey']; } $options[ $label ] = $item['embedKey']; } return $options; } /** * Whether WPBakery's front-end editor is showing the page, or loading an element into it. * * @return bool */ public static function is_editor() { return ( function_exists( 'vc_is_page_editable' ) && vc_is_page_editable() ) || ( function_exists( 'vc_is_inline' ) && vc_is_inline() ); } /** * In WPBakery's front-end editor the element shows the module's still (scripts loaded into the editor would not * start the module reliably); the page itself renders the module. * * @param false|string $output What runs instead of the shortcode (false: the shortcode runs). * @param string $tag The shortcode's tag. * @param array|string $attr Its attributes. * @return false|string */ public static function still_in_editor( $output, $tag, $attr ) { if ( self::TAG !== $tag || false !== $output || ! self::is_editor() ) { return $output; } $key = is_array( $attr ) && isset( $attr['key'] ) ? trim( (string) $attr['key'] ) : ''; return Picker::still( $key, __( 'Pick a module in the element\'s settings.', 'sr-anywhere' ) ); } /** * The still's look in the front-end editor (WPBakery's element list shows the SR mark as the element's icon). */ public static function editor_styles() { if ( self::is_editor() ) { Picker::enqueue_still_styles(); } } }