Import legacy nurinda.co.id website
No files matched your search
@@ -0,0 +1,156 @@
|
||||
|
||||
/* Enable WPML, Polylang meta boxes
|
||||
========================================================================== */
|
||||
.wp-admin #post-body.columns-2 #postbox-container-1 {
|
||||
margin-right: -270px;
|
||||
width: 300px;
|
||||
}
|
||||
.rtl.wp-admin #post-body.columns-2 #postbox-container-1 {
|
||||
margin-left: -270px;
|
||||
margin-right: 0;
|
||||
}
|
||||
.wp-admin #post-body.columns-2 #side-sortables {
|
||||
min-height: 0;
|
||||
}
|
||||
.wp-admin #poststuff #post-body.columns-2 #side-sortables {
|
||||
width: auto;
|
||||
}
|
||||
.wp-admin .postbox#ml_box,
|
||||
.wp-admin .postbox#icl_div {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
/* Builder Workspace
|
||||
========================================================================== */
|
||||
.us-bld-editor-row {
|
||||
max-width: none;
|
||||
margin: 0 0 -2px;
|
||||
box-shadow: 0 0 0 5px transparent;
|
||||
transition: opacity 0.2s, box-shadow 0.2s;
|
||||
}
|
||||
.us-bld-editor-row-h {
|
||||
display: flex;
|
||||
min-height: 76px;
|
||||
}
|
||||
.us-bld-editor-cell {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
align-items: center;
|
||||
border-right: 1px dotted #ddd;
|
||||
}
|
||||
.us-bld-editor-cell.at_left {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.us-bld-editor-cell.at_center {
|
||||
justify-content: center;
|
||||
}
|
||||
.us-bld-editor-cell.at_right {
|
||||
justify-content: flex-end;
|
||||
border-right-width: 0;
|
||||
}
|
||||
.us-bld-editor-add {
|
||||
margin: 12px 2px;
|
||||
}
|
||||
|
||||
/* Highlight areas on hover */
|
||||
.us-bld-editor.highlight_top .us-bld-editor-row.at_top,
|
||||
.us-bld-editor.highlight_middle .us-bld-editor-row.at_middle,
|
||||
.us-bld-editor.highlight_bottom .us-bld-editor-row.at_bottom {
|
||||
box-shadow: 0 0 0 5px #fe0;
|
||||
border-color: #fe0;
|
||||
border-style: solid;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* Fade disabled area */
|
||||
.us-bld-editor-row.disabled {
|
||||
opacity: 0.33;
|
||||
}
|
||||
|
||||
/* Vertical Orientation */
|
||||
.us-bld-editor.type_ver .us-bld-editor-row:not(.for_hidden) {
|
||||
max-width: 400px;
|
||||
}
|
||||
.us-bld-editor.type_ver .us-bld-editor-row:not(.for_hidden) .us-bld-editor-row-h {
|
||||
min-height: 0;
|
||||
}
|
||||
.us-bld-editor.type_ver .us-bld-editor-cell {
|
||||
display: block;
|
||||
width: auto;
|
||||
border: none;
|
||||
}
|
||||
.us-bld-editor.type_ver .us-bld-editor-cell.at_center,
|
||||
.us-bld-editor.type_ver .us-bld-editor-cell.at_right {
|
||||
display: none;
|
||||
}
|
||||
.us-bld-editor.type_ver .us-bld-editor-row:not(.for_hidden) .us-bld-editor-cell > * {
|
||||
max-width: 376px;
|
||||
}
|
||||
.us-bld-editor.type_ver .us-bld-editor-add {
|
||||
margin: 4px auto;
|
||||
}
|
||||
.us-bld-editor.type_ver .us-bld-editor-wrapper.type_horizontal + .us-bld-editor-add {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.us-bld-editor-elm {
|
||||
min-width: 100px;
|
||||
max-width: 300px;
|
||||
}
|
||||
|
||||
/* Hide certain elements */
|
||||
.us-bld-window.orientation_ver.addto_cell .us-bld-window-item.type_vwrapper,
|
||||
.us-bld-window.addto_vwrapper .us-bld-window-item.type_vwrapper,
|
||||
.us-bld-editor-elm.type_image .us-bld-editor-elm-content:before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Header Templates */
|
||||
.us-bld-window.for_templates .us-bld-window-item.type_htemplate {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* RTL STYLES
|
||||
========================================================================== */
|
||||
.rtl .us-bld-editor-cell.at_left {
|
||||
border-right-width: 0;
|
||||
}
|
||||
.rtl .us-bld-editor-cell.at_right {
|
||||
border-right-width: 1px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* RESPONSIVE STYLES
|
||||
========================================================================== */
|
||||
@media ( max-width: 1400px ) {
|
||||
.us-bld-workspace {
|
||||
padding: 20px;
|
||||
}
|
||||
.us-bld-editor {
|
||||
padding-right: 20px;
|
||||
}
|
||||
.rtl .us-bld-editor {
|
||||
padding-left: 20px;
|
||||
padding-right: 0;
|
||||
}
|
||||
.us-bld-editor-elm {
|
||||
max-width: 180px;
|
||||
}
|
||||
}
|
||||
@media ( max-width: 1280px ) {
|
||||
.us-bld-workspace {
|
||||
display: block;
|
||||
}
|
||||
.us-bld-editor {
|
||||
padding: 0 0 20px;
|
||||
}
|
||||
.us-bld-editor-elm {
|
||||
max-width: 120px;
|
||||
}
|
||||
.us-bld-window.for_templates .us-bld-window-item.type_htemplate {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 166 KiB |
|
After Width: | Height: | Size: 170 KiB |
@@ -0,0 +1,88 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Header Builder Meta Boxes changes.
|
||||
*
|
||||
* @var $config array Framework- and theme-defined metaboxes config
|
||||
*
|
||||
* @return array Changed config
|
||||
*/
|
||||
|
||||
foreach ( $config as &$cfg ) {
|
||||
if ( $cfg['id'] === 'us_page_settings' ) {
|
||||
$cfg['fields'] = us_array_merge_insert(
|
||||
$cfg['fields'], array(
|
||||
'us_header_sticky_override' => array(
|
||||
'title' => __( 'Sticky Header', 'us' ),
|
||||
'type' => 'switch',
|
||||
'switch_text' => __( 'Override this setting', 'us' ),
|
||||
'std' => 0,
|
||||
'classes' => 'for_above',
|
||||
'show_if' => array( 'us_header_id', 'not in', array( '__defaults__', '' ) ),
|
||||
),
|
||||
'us_header_sticky' => array(
|
||||
'type' => 'checkboxes',
|
||||
'options' => array(
|
||||
'default' => __( 'On Desktops', 'us' ),
|
||||
'tablets' => __( 'On Tablets', 'us' ),
|
||||
'mobiles' => __( 'On Mobiles', 'us' ),
|
||||
),
|
||||
'std' => array(),
|
||||
'classes' => 'for_above',
|
||||
'show_if' => array(
|
||||
array( 'us_header_id', 'not in', array( '__defaults__', '' ) ),
|
||||
'and',
|
||||
array( 'us_header_sticky_override', '=', '1' ),
|
||||
),
|
||||
),
|
||||
'us_header_transparent_override' => array(
|
||||
'title' => __( 'Transparent Header', 'us' ),
|
||||
'type' => 'switch',
|
||||
'switch_text' => __( 'Override this setting', 'us' ),
|
||||
'std' => 0,
|
||||
'classes' => 'for_above',
|
||||
'show_if' => array( 'us_header_id', 'not in', array( '__defaults__', '' ) ),
|
||||
),
|
||||
'us_header_transparent' => array(
|
||||
'type' => 'checkboxes',
|
||||
'options' => array(
|
||||
'default' => __( 'On Desktops', 'us' ),
|
||||
'tablets' => __( 'On Tablets', 'us' ),
|
||||
'mobiles' => __( 'On Mobiles', 'us' ),
|
||||
),
|
||||
'std' => array(),
|
||||
'classes' => 'for_above',
|
||||
'show_if' => array(
|
||||
array( 'us_header_id', 'not in', array( '__defaults__', '' ) ),
|
||||
'and',
|
||||
array( 'us_header_transparent_override', '=', '1' ),
|
||||
),
|
||||
),
|
||||
'us_header_shadow' => array(
|
||||
'title' => __( 'Header Shadow', 'us' ),
|
||||
'type' => 'switch',
|
||||
'switch_text' => __( 'Remove header shadow', 'us' ),
|
||||
'std' => 0,
|
||||
'classes' => 'for_above',
|
||||
'show_if' => array( 'us_header_id', 'not in', array( '__defaults__', '' ) ),
|
||||
),
|
||||
'us_header_sticky_pos' => array(
|
||||
'title' => __( 'Sticky Header Initial Position', 'us' ),
|
||||
'type' => 'select',
|
||||
'options' => array(
|
||||
'' => __( 'At the Top of this page', 'us' ),
|
||||
'bottom' => __( 'At the Bottom of the first content row', 'us' ),
|
||||
'above' => __( 'Above the first content row', 'us' ),
|
||||
'below' => __( 'Below the first content row', 'us' ),
|
||||
),
|
||||
'std' => '',
|
||||
'classes' => 'for_above',
|
||||
'show_if' => array( 'us_header_id', 'not in', array( '__defaults__', '' ) ),
|
||||
),
|
||||
), 'after', 'us_header_id'
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $config;
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Header Theme Options changes.
|
||||
*
|
||||
* @var $config array Framework- and theme-defined theme options config
|
||||
*
|
||||
* @return array Changed config
|
||||
*/
|
||||
|
||||
// Hide the 'Headers' section, which is overloaded by Header Builder
|
||||
$config['header']['place_if'] = FALSE;
|
||||
|
||||
return $config;
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Load elements list HTML to choose from
|
||||
*/
|
||||
add_action( 'wp_ajax_ushb_get_elist_html', 'ajax_ushb_get_elist_html' );
|
||||
function ajax_ushb_get_elist_html() {
|
||||
us_load_template(
|
||||
'templates/elist', array(
|
||||
'elements' => us_config( 'header-settings.elements', array() ),
|
||||
)
|
||||
);
|
||||
|
||||
// We don't use JSON to reduce data size
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load shortcode builder elements forms
|
||||
*/
|
||||
add_action( 'wp_ajax_ushb_get_ebuilder_html', 'ajax_ushb_get_ebuilder_html' );
|
||||
function ajax_ushb_get_ebuilder_html() {
|
||||
$template_vars = array(
|
||||
'titles' => array(),
|
||||
'body' => '',
|
||||
);
|
||||
|
||||
// Loading all the forms HTML
|
||||
foreach ( us_config( 'header-settings.elements', array() ) as $type ) {
|
||||
$elm = us_config( 'elements/' . $type );
|
||||
$template_vars['titles'][ $type ] = isset( $elm['title'] ) ? $elm['title'] : $type;
|
||||
$template_vars['body'] .= us_get_template(
|
||||
'templates/eform', array(
|
||||
'type' => $type,
|
||||
'params' => $elm['params'],
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
us_load_template( 'templates/ebuilder', $template_vars );
|
||||
|
||||
// We don't use JSON to reduce data size
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load header template selector forms
|
||||
*/
|
||||
add_action( 'wp_ajax_ushb_get_htemplates_html', 'ajax_ushb_get_htemplates_html' );
|
||||
function ajax_ushb_get_htemplates_html() {
|
||||
us_load_template( 'templates/htemplates' );
|
||||
|
||||
// We don't use JSON to reduce data size
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save header
|
||||
*/
|
||||
add_action( 'wp_ajax_ushb_save', 'ajax_ushb_save' );
|
||||
function ajax_ushb_save() {
|
||||
$post = array(
|
||||
'ID' => isset( $_POST['ID'] ) ? intval( $_POST['ID'] ) : NULL,
|
||||
'post_title' => isset( $_POST['post_title'] ) ? $_POST['post_title'] : NULL,
|
||||
'post_content' => isset( $_POST['post_content'] ) ? $_POST['post_content'] : NULL,
|
||||
);
|
||||
|
||||
if ( ! check_admin_referer( 'ushb-update' ) OR ! current_user_can( 'edit_post', $post['ID'] ) ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'message' => us_translate( 'An error has occurred. Please reload the page and try again.' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! $post['ID'] ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'message' => us_translate( 'An error has occurred. Please reload the page and try again.' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( wp_update_post( $post ) !== $post['ID'] ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'message' => us_translate( 'An error has occurred. Please reload the page and try again.' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
'message' => us_translate( 'Changes saved.' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Output elements list to choose from
|
||||
*
|
||||
* @var $body string Optional predefined body
|
||||
*/
|
||||
global $ushb_uri;
|
||||
|
||||
$templates = us_config( 'header-templates', array() );
|
||||
if ( ! isset( $body ) ) {
|
||||
$body = '<ul class="us-bld-window-list">';
|
||||
foreach ( $templates as $name => $template ) {
|
||||
$template_title = isset( $template['title'] ) ? $template['title'] : ucfirst( $name );
|
||||
$template = us_fix_header_template_settings( $template );
|
||||
// Hiding text logo as we'll use only the image logo
|
||||
foreach ( array( 'default', 'tablets', 'mobiles' ) as $layout ) {
|
||||
foreach ( $template[ $layout ]['layout'] as $cell => $cell_elms ) {
|
||||
if ( $cell == 'hidden' ) {
|
||||
continue;
|
||||
}
|
||||
if ( ( $elm_pos = array_search( 'text:1', $cell_elms ) ) !== FALSE ) {
|
||||
array_splice( $template[ $layout ]['layout'][ $cell ], $elm_pos, 1 );
|
||||
$template[ $layout ]['layout']['hidden'][] = 'text:1';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$body .= '<li data-name="' . esc_attr( $name ) . '" class="us-bld-window-item type_htemplate ' . $name . '">';
|
||||
$body .= '<div class="us-bld-window-item-h">';
|
||||
$body .= '<div class="us-bld-window-item-icon">';
|
||||
$body .= '<img src="' . $ushb_uri . '/admin/img/header-templates/' . $name . '.jpg" />';
|
||||
$body .= '</div>';
|
||||
$body .= '<div class="us-bld-window-item-title">' . $template_title . '</div>';
|
||||
$body .= '<div class="us-bld-window-item-data"' . us_pass_data_to_js( $template ) . '></div>';
|
||||
$body .= '</div>';
|
||||
$body .= '</li>';
|
||||
}
|
||||
$body .= '</ul>';
|
||||
}
|
||||
|
||||
$output = '<div class="us-bld-window for_templates"><div class="us-bld-window-h">';
|
||||
$output .= '<div class="us-bld-window-header"><div class="us-bld-window-title">' . __( 'Header Templates', 'us' ) . '</div><div class="us-bld-window-closer" title="' . us_translate( 'Close' ) . '"></div></div>';
|
||||
$output .= '<div class="us-bld-window-body">';
|
||||
$output .= $body;
|
||||
$output .= '<span class="usof-preloader"></span>';
|
||||
$output .= '</div>';
|
||||
$output .= '</div></div>';
|
||||
|
||||
echo $output;
|
||||
@@ -0,0 +1,450 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Plugin Name: Header Builder
|
||||
* Plugin URI: https://us-themes.com/
|
||||
* Description: UpSolution Themes addon that allows to create website headers with custom layout and any elements.
|
||||
* Author: UpSolution
|
||||
* Author URI: https://us-themes.com/
|
||||
* Version: 2.5.1
|
||||
**/
|
||||
|
||||
// Define current themes version compatibility
|
||||
function ushb_get_required_theme_version() {
|
||||
return array(
|
||||
'Impreza' => '6.0',
|
||||
'Zephyr' => '6.0',
|
||||
);
|
||||
}
|
||||
|
||||
// Global variables for plugin usage
|
||||
$ushb_file = __FILE__;
|
||||
$ushb_dir = plugin_dir_path( __FILE__ );
|
||||
$ushb_uri = plugins_url( '', __FILE__ );
|
||||
if ( ! function_exists( 'get_plugin_data' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
$ushb_data = get_plugin_data( __FILE__ );
|
||||
$ushb_version = $ushb_data['Version'] ? $ushb_data['Version'] : FALSE;
|
||||
if ( $ushb_version ) {
|
||||
define( 'US_HB_VERSION', $ushb_version );
|
||||
}
|
||||
unset( $ushb_matches );
|
||||
|
||||
// Check current UpSolution theme compatibility with the plugin
|
||||
add_action( 'after_setup_theme', 'ushb_check_theme_compatibility' );
|
||||
function ushb_check_theme_compatibility() {
|
||||
if ( ! defined( 'US_THEMENAME' ) OR ! defined( 'US_THEMEVERSION' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ushb_required_theme_version = ushb_get_required_theme_version();
|
||||
|
||||
if ( isset( $ushb_required_theme_version[ US_THEMENAME ] ) AND version_compare( US_THEMEVERSION, $ushb_required_theme_version[ US_THEMENAME ], '<' ) ) {
|
||||
add_action( 'admin_notices', 'ushb_check_theme_compatibility_error' );
|
||||
}
|
||||
function ushb_check_theme_compatibility_error() {
|
||||
$ushb_required_theme_version = ushb_get_required_theme_version();
|
||||
|
||||
$output = '<div class="notice notice-warning us-addons-notice">';
|
||||
$output .= '<p>' . sprintf( __( 'Header Builder plugin requires %s version %s.', 'us' ), US_THEMENAME, $ushb_required_theme_version[ US_THEMENAME ] ) . ' <a href="' . admin_url( 'themes.php' ) . '">' . __( 'Update the theme', 'us' ) . '</a>.</p>';
|
||||
$output .= '</div>';
|
||||
|
||||
echo $output;
|
||||
}
|
||||
}
|
||||
|
||||
// Adding special plugin-related paths for admin area only (for performance reasons)
|
||||
add_filter( 'us_files_search_paths', 'ushb_files_search_paths' );
|
||||
function ushb_files_search_paths( $paths ) {
|
||||
global $ushb_dir;
|
||||
array_splice( $paths, 1, 0, $ushb_dir );
|
||||
|
||||
return $paths;
|
||||
}
|
||||
|
||||
// Ajax requests
|
||||
if ( is_admin() AND isset( $_POST['action'] ) AND substr( $_POST['action'], 0, 5 ) == 'ushb_' ) {
|
||||
require $ushb_dir . 'functions/ajax.php';
|
||||
}
|
||||
|
||||
add_filter( 'usof_container_classes', 'ushb_usof_container_classes' );
|
||||
function ushb_usof_container_classes( $classes ) {
|
||||
return $classes . ' with_hb';
|
||||
}
|
||||
|
||||
register_activation_hook( $ushb_file, 'ushb_activate' );
|
||||
function ushb_activate() {
|
||||
if ( ! get_posts(
|
||||
array(
|
||||
'post_type' => 'us_header',
|
||||
'post_status' => 'any',
|
||||
'numberposts' => 1,
|
||||
)
|
||||
) ) {
|
||||
global $usof_options, $us_header_settings;
|
||||
remove_filter( 'us_load_header_settings', 'ushb_load_header_settings', 9 );
|
||||
if ( function_exists( 'usof_load_options_once' ) ) {
|
||||
usof_load_options_once();
|
||||
}
|
||||
us_load_header_settings_once();
|
||||
|
||||
// Filling cells with missing keys
|
||||
foreach ( array( 'default', 'tablets', 'mobiles' ) AS $state ) {
|
||||
$us_header_settings[ $state ]['layout'] = us_get_header_layout( $state );
|
||||
}
|
||||
|
||||
foreach ( $us_header_settings['data'] as $elm_key => $data ) {
|
||||
foreach ( $data as $data_key => $data_val ) {
|
||||
if ( is_array( $data_val ) ) {
|
||||
foreach ( $data_val as $data_subkey => $data_subval ) {
|
||||
if ( strpos( $data_subval, '"' ) !== FALSE ) {
|
||||
$us_header_settings['data'][ $elm_key ][ $data_key ][ $data_subkey ] = str_replace( '"', '\"', $data_subval );
|
||||
}
|
||||
}
|
||||
} elseif ( strpos( $data_val, '"' ) !== FALSE ) {
|
||||
$us_header_settings['data'][ $elm_key ][ $data_key ] = str_replace( '"', '\"', $data_val );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$header_post_array = array(
|
||||
'post_type' => 'us_header',
|
||||
'post_date' => date( 'Y-m-d H:i', time() ),
|
||||
'post_name' => 'site-header-1',
|
||||
'post_title' => sprintf( __( 'Site Header %d', 'us' ), 1 ),
|
||||
'post_content' => json_encode( $us_header_settings, JSON_UNESCAPED_UNICODE ),
|
||||
'post_status' => 'publish',
|
||||
);
|
||||
|
||||
remove_action( 'init', 'ushb_create_post_types', 8 );
|
||||
ushb_create_post_types();
|
||||
|
||||
$default_header_id = wp_insert_post( $header_post_array );
|
||||
|
||||
$updated_options = $usof_options;
|
||||
$updated_options['header_id'] = $default_header_id;
|
||||
usof_save_options( $updated_options );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
register_uninstall_hook( $ushb_file, 'ushb_uninstall' );
|
||||
function ushb_uninstall() {
|
||||
global $usof_options;
|
||||
usof_load_options_once();
|
||||
|
||||
if ( isset( $usof_options['header'] ) ) {
|
||||
// Removing header builder setting
|
||||
$updated_options = $usof_options;
|
||||
unset( $updated_options['header'] );
|
||||
usof_save_options( $updated_options );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add_filter( 'us_load_header_settings', 'ushb_load_header_settings', 9 );
|
||||
function ushb_load_header_settings( $header_settings ) {
|
||||
global $us_header_id;
|
||||
remove_filter( 'us_load_header_settings', 'us_load_usof_header_settings' );
|
||||
if ( function_exists( 'us_get_public_cpt' ) ) {
|
||||
$public_cpt = array_keys( us_get_public_cpt() );
|
||||
} else {
|
||||
$public_cpt = array();
|
||||
}
|
||||
|
||||
// Get Header ID from Theme Options
|
||||
$us_header_id = us_get_page_area_id( 'header' );
|
||||
|
||||
// Override Header ID and its settings for certain post when they set in metabox
|
||||
$states = array( 'default', 'tablets', 'mobiles' );
|
||||
$override_options = array();
|
||||
if ( is_singular() ) {
|
||||
$postID = get_the_ID();
|
||||
}
|
||||
if ( is_404() ) {
|
||||
$postID = us_get_option( 'page_404' );
|
||||
}
|
||||
if ( is_search() AND ! is_post_type_archive( 'product' ) ) {
|
||||
$postID = us_get_option( 'search_page' );
|
||||
}
|
||||
if ( is_home() ) {
|
||||
$postID = us_get_option( 'posts_page' );
|
||||
}
|
||||
if ( ! empty( $postID ) AND $postID != 'default' ) {
|
||||
if ( usof_meta( 'us_header_id', array(), $postID ) != '__defaults__' ) {
|
||||
if ( class_exists( 'SitePress' ) AND defined( 'ICL_LANGUAGE_CODE' ) ) {
|
||||
global $sitepress;
|
||||
if ( $sitepress->get_default_language() != ICL_LANGUAGE_CODE ) {
|
||||
$original_postID = apply_filters( 'wpml_object_id', $postID, get_post_type( $postID ), TRUE, $sitepress->get_default_language() );
|
||||
if ( $original_postID != $postID ) {
|
||||
$us_header_id = usof_meta( 'us_header_id', array(), $original_postID );
|
||||
$us_header_id = apply_filters( 'wpml_object_id', $us_header_id, 'us_header', TRUE, ICL_LANGUAGE_CODE );
|
||||
}
|
||||
}
|
||||
} elseif ( function_exists( 'pll_default_language' ) AND pll_get_post( $postID ) ) {
|
||||
if ( pll_current_language() != pll_default_language() ) {
|
||||
$original_postID = pll_get_post( $postID, pll_default_language() );
|
||||
if ( $original_postID != $postID ) {
|
||||
$us_header_id = usof_meta( 'us_header_id', array(), $original_postID );
|
||||
$us_header_id = pll_get_post( $us_header_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( usof_meta( 'us_header_sticky_override', array(), $postID ) ) {
|
||||
$sticky_override = usof_meta( 'us_header_sticky', array(), $postID );
|
||||
if ( ! is_array( $sticky_override ) ) {
|
||||
$sticky_override = array();
|
||||
}
|
||||
foreach ( $states as $state ) {
|
||||
$override_options[ $state ]['options']['sticky'] = in_array( $state, $sticky_override );
|
||||
}
|
||||
}
|
||||
if ( usof_meta( 'us_header_transparent_override', array(), $postID ) ) {
|
||||
$transparent_override = usof_meta( 'us_header_transparent', array(), $postID );
|
||||
if ( ! is_array( $transparent_override ) ) {
|
||||
$transparent_override = array();
|
||||
}
|
||||
foreach ( $states as $state ) {
|
||||
$override_options[ $state ]['options']['transparent'] = in_array( $state, $transparent_override );
|
||||
}
|
||||
}
|
||||
if ( usof_meta( 'us_header_shadow', array(), $postID ) ) {
|
||||
foreach ( $states as $state ) {
|
||||
$override_options[ $state ]['options']['shadow'] = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset Header ID to Defaults if set
|
||||
if ( $us_header_id == '__defaults__' ) {
|
||||
$us_header_id = us_get_option( 'header_id' );
|
||||
}
|
||||
|
||||
// Generate header settings from Header post content
|
||||
if ( $us_header_id != '' ) {
|
||||
if ( class_exists( 'SitePress' ) AND defined( 'ICL_LANGUAGE_CODE' ) ) {
|
||||
$us_header_id = apply_filters( 'wpml_object_id', $us_header_id, 'us_header', TRUE );
|
||||
} elseif ( function_exists( 'pll_default_language' ) AND pll_get_post( $us_header_id ) ) {
|
||||
$us_header_id = pll_get_post( $us_header_id );
|
||||
}
|
||||
$header = get_post( (int) $us_header_id );
|
||||
if ( $header instanceof WP_Post AND $header->post_type === 'us_header' ) {
|
||||
if ( ! empty( $header->post_content ) AND substr( strval( $header->post_content ), 0, 1 ) === '{' ) {
|
||||
try {
|
||||
$header_settings = json_decode( $header->post_content, TRUE );
|
||||
}
|
||||
catch ( Exception $e ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Add Header ID to settings
|
||||
$header_settings['header_id'] = $us_header_id;
|
||||
|
||||
} else {
|
||||
$header_settings['is_hidden'] = TRUE;
|
||||
}
|
||||
|
||||
// Merge header settings with metabox settings
|
||||
$header_settings = us_array_merge( $header_settings, $override_options );
|
||||
|
||||
return $header_settings;
|
||||
}
|
||||
|
||||
add_action( 'init', 'ushb_create_post_types', 8 );
|
||||
function ushb_create_post_types() {
|
||||
|
||||
// Header post type
|
||||
register_post_type(
|
||||
'us_header', array(
|
||||
'labels' => array(
|
||||
'name' => _x( 'Headers', 'site top area', 'us' ),
|
||||
'singular_name' => _x( 'Header', 'site top area', 'us' ),
|
||||
'add_new' => _x( 'Add Header', 'site top area', 'us' ),
|
||||
'add_new_item' => _x( 'Add Header', 'site top area', 'us' ),
|
||||
'edit_item' => _x( 'Edit Header', 'site top area', 'us' ),
|
||||
),
|
||||
'public' => TRUE,
|
||||
'show_in_menu' => 'us-theme-options',
|
||||
'exclude_from_search' => TRUE,
|
||||
'show_in_admin_bar' => FALSE,
|
||||
'publicly_queryable' => FALSE,
|
||||
'show_in_nav_menus' => FALSE,
|
||||
'capability_type' => array( 'us_page_block', 'us_page_blocks' ),
|
||||
'map_meta_cap' => TRUE,
|
||||
'supports' => FALSE,
|
||||
'rewrite' => FALSE,
|
||||
'register_meta_box_cb' => 'ushb_us_header_type_pages',
|
||||
)
|
||||
);
|
||||
|
||||
// Add "Used in" column into Headers admin page
|
||||
add_filter( 'manage_us_header_posts_columns', 'ushb_us_header_columns_head' );
|
||||
add_action( 'manage_us_header_posts_custom_column', 'ushb_us_header_columns_content', 10, 2 );
|
||||
|
||||
function ushb_us_header_columns_head( $defaults ) {
|
||||
$result = array();
|
||||
foreach ( $defaults as $key => $title ) {
|
||||
if ( $key == 'date' ) {
|
||||
$result['used_in'] = __( 'Used in', 'us' );
|
||||
}
|
||||
$result[ $key ] = $title;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function ushb_us_header_columns_content( $column_name, $post_ID ) {
|
||||
if ( $column_name == 'used_in' ) {
|
||||
if ( function_exists( 'us_get_used_in_locations' ) ) {
|
||||
echo us_get_used_in_locations( $post_ID );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ushb_us_header_type_pages() {
|
||||
global $post;
|
||||
// Dev note: This check is not necessary, but still wanted to make sure this function won't be bound somewhere else
|
||||
if ( ! ( $post instanceof WP_Post ) OR $post->post_type !== 'us_header' ) {
|
||||
return;
|
||||
}
|
||||
if ( $post->post_status === 'auto-draft' ) {
|
||||
// Page for creating new header: creating it instantly and proceeding to editing
|
||||
$post_data = array( 'ID' => $post->ID );
|
||||
// Retrieving occupied names to generate new post title properly
|
||||
$existing_headers = us_get_posts_titles_for( 'us_header' );
|
||||
if ( isset( $_GET['duplicate_from'] ) AND ( $original_post = get_post( (int) $_GET['duplicate_from'] ) ) !== NULL ) {
|
||||
// Handling post duplication
|
||||
$post_data['post_content'] = wp_slash( $original_post->post_content );
|
||||
$title_pattern = $original_post->post_title . ' (%d)';
|
||||
$cur_index = 2;
|
||||
} else {
|
||||
// Handling creation from scratch
|
||||
$title_pattern = __( 'Site Header %d', 'us' );
|
||||
$cur_index = count( $existing_headers ) + 1;
|
||||
}
|
||||
// Generating new post title
|
||||
while ( in_array( $post_data['post_title'] = sprintf( $title_pattern, $cur_index ), $existing_headers ) ) {
|
||||
$cur_index ++;
|
||||
}
|
||||
wp_update_post( $post_data );
|
||||
wp_publish_post( $post->ID );
|
||||
// Redirect
|
||||
if ( isset( $_GET['duplicate_from'] ) ) {
|
||||
// When duplicating post, showing posts list next
|
||||
wp_redirect( admin_url( 'edit.php?post_type=us_header' ) );
|
||||
} else {
|
||||
// When creating from scratch proceeding to post editing next
|
||||
wp_redirect( admin_url( 'post.php?post=' . $post->ID . '&action=edit' ) );
|
||||
}
|
||||
} else {
|
||||
// Page for editing a header
|
||||
add_action( 'admin_enqueue_scripts', 'ushb_enqueue_scripts' );
|
||||
add_action( 'edit_form_top', 'ushb_edit_form_top' );
|
||||
}
|
||||
}
|
||||
|
||||
function ushb_enqueue_scripts() {
|
||||
// Appending dependencies
|
||||
usof_print_styles();
|
||||
usof_print_scripts();
|
||||
|
||||
// Appending required assets
|
||||
global $ushb_uri, $ushb_version;
|
||||
$protocol = is_ssl() ? 'https' : 'http';
|
||||
wp_enqueue_style( 'us-header-builder', $ushb_uri . '/admin/css/header-builder.css', array(), $ushb_version );
|
||||
wp_enqueue_script( 'us-header-builder', $ushb_uri . '/admin/js/header-builder.js', array( 'usof-scripts' ), $ushb_version, TRUE );
|
||||
|
||||
// Disabling WP auto-save
|
||||
wp_dequeue_script( 'autosave' );
|
||||
}
|
||||
|
||||
function ushb_edit_form_top( $post ) {
|
||||
echo '<div class="usof-container type_builder';
|
||||
if ( get_option( 'us_license_activated', 0 ) OR ( defined( 'US_DEV' ) AND US_DEV ) OR defined( 'US_THEME_BETA' ) ) {
|
||||
echo ' theme_activated';
|
||||
}
|
||||
echo '" data-ajaxurl="' . esc_attr( admin_url( 'admin-ajax.php' ) ) . '" data-id="' . esc_attr( $post->ID ) . '">';
|
||||
echo '<form class="usof-form" method="post" action="#" autocomplete="off">';
|
||||
// Output _nonce and _wp_http_referer hidden fields for ajax secuirity checks
|
||||
wp_nonce_field( 'ushb-update' );
|
||||
echo '<div class="usof-header">';
|
||||
echo '<div class="usof-header-title">' . _x( 'Edit Header', 'site top area', 'us' ) . '</div>';
|
||||
|
||||
us_load_template(
|
||||
'vendor/usof/templates/field', array(
|
||||
'name' => 'post_title',
|
||||
'id' => 'usof_header_title',
|
||||
'field' => array(
|
||||
'type' => 'text',
|
||||
'placeholder' => __( 'Header Name', 'us' ),
|
||||
'classes' => 'desc_0', // Reset desc position of global HB field
|
||||
),
|
||||
'values' => array(
|
||||
'post_title' => $post->post_title,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
echo '<div class="usof-control for_help"><a href="https://help.us-themes.com/' . strtolower( US_THEMENAME ) . '/hb/" target="_blank" title="' . us_translate( 'Help' ) . '"></a></div>';
|
||||
echo '<div class="usof-control for_import"><a href="#" title="' . __( 'Header Export / Import', 'us' ) . '"></a></div>';
|
||||
echo '<div class="usof-control for_templates">';
|
||||
echo '<a href="#" title="' . __( 'Header Templates', 'us' ) . '"></a>';
|
||||
echo '<div class="usof-control-desc"><span>' . __( 'Choose Header template to start with', 'us' ) . '</span></div>';
|
||||
echo '</div>';
|
||||
echo '<div class="usof-control for_save status_clear">';
|
||||
echo '<button class="usof-button type_save" type="button"><span>' . us_translate( 'Save Changes' ) . '</span>';
|
||||
echo '<span class="usof-preloader"></span></button>';
|
||||
echo '<div class="usof-control-message"></div></div></div>';
|
||||
|
||||
us_load_template(
|
||||
'vendor/usof/templates/field', array(
|
||||
'name' => 'post_content',
|
||||
'id' => 'usof_header',
|
||||
'field' => array(
|
||||
'type' => 'header_builder',
|
||||
'classes' => 'desc_0', // Reset desc position of global HB field
|
||||
),
|
||||
'values' => array(
|
||||
'post_content' => $post->post_content,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
// Add link to duplicate headers in admin area
|
||||
add_filter( 'post_row_actions', 'ushb_post_row_actions', 10, 2 );
|
||||
function ushb_post_row_actions( $actions, $post ) {
|
||||
if ( $post->post_type === 'us_header' ) {
|
||||
// Removing duplicate post plugin affection
|
||||
unset( $actions['duplicate'], $actions['edit_as_new_draft'] );
|
||||
$actions = us_array_merge_insert(
|
||||
$actions, array(
|
||||
'duplicate' => '<a href="' . admin_url( 'post-new.php?post_type=us_header&duplicate_from=' . $post->ID ) . '" aria-label="' . esc_attr__( 'Duplicate', 'us' ) . '">' . esc_html__( 'Duplicate', 'us' ) . '</a>',
|
||||
), 'before', isset( $actions['trash'] ) ? 'trash' : 'untrash'
|
||||
);
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
// Add link to Admin bar to edit the current header
|
||||
add_filter( 'admin_bar_menu', 'ushb_admin_bar_menu', 500 );
|
||||
function ushb_admin_bar_menu( $wp_admin_bar ) {
|
||||
global $us_header_id;
|
||||
if ( $us_header_id != '' AND current_user_can( 'administrator' ) ) {
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'ushb-edit-header',
|
||||
'title' => _x( 'Edit Header', 'site top area', 'us' ),
|
||||
'href' => admin_url( 'post.php?post=' . intval( $us_header_id ) . '&action=edit' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: header_builder
|
||||
*
|
||||
* Advanced header builder.
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @var $value array Current value
|
||||
*/
|
||||
global $usof_directory, $usof_directory_uri;
|
||||
|
||||
if ( ! empty( $value ) AND is_string( $value ) AND $value[0] === '{' ) {
|
||||
$value = json_decode( $value, TRUE );
|
||||
}
|
||||
$value = us_fix_header_settings( $value );
|
||||
|
||||
$output = '<div class="us-bld" data-ajaxurl="' . esc_attr( admin_url( 'admin-ajax.php' ) ) . '">';
|
||||
|
||||
// States
|
||||
$output .= '<div class="us-bld-states">';
|
||||
$output .= '<div class="us-bld-state for_default active">' . us_translate( 'Default' ) . '</div>';
|
||||
$output .= '<div class="us-bld-state for_tablets">' . __( 'Tablets', 'us' ) . '</div>';
|
||||
$output .= '<div class="us-bld-state for_mobiles">' . __( 'Mobiles', 'us' ) . '</div>';
|
||||
$output .= '</div>';
|
||||
|
||||
// Workspace
|
||||
$output .= '<div class="us-bld-workspace for_default">';
|
||||
|
||||
// Editor
|
||||
if ( ! function_exists( 'ushb_get_elms_placeholders' ) ) {
|
||||
/**
|
||||
* Prepare HTML for elements list for a certain elements area
|
||||
*
|
||||
* @param array $layout
|
||||
* @param array $data Elements data
|
||||
* @param string $place
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function ushb_get_elms_placeholders( &$layout, &$data, $place ) {
|
||||
$output = '';
|
||||
if ( ! isset( $layout[ $place ] ) OR ! is_array( $layout[ $place ] ) ) {
|
||||
return $output;
|
||||
}
|
||||
foreach ( $layout[ $place ] as $elm ) {
|
||||
if ( substr( $elm, 1, 7 ) == 'wrapper' ) {
|
||||
$output .= '<div class="us-bld-editor-wrapper type_' . ( ( $elm[0] == 'h' ) ? 'horizontal' : 'vertical' );
|
||||
if ( ! isset( $layout[ $elm ] ) OR empty( $layout[ $elm ] ) ) {
|
||||
$output .= ' empty';
|
||||
}
|
||||
$output .= '" data-id="' . esc_attr( $elm ) . '">';
|
||||
$output .= '<div class="us-bld-editor-wrapper-content">';
|
||||
$output .= ushb_get_elms_placeholders( $layout, $data, $elm );
|
||||
$output .= '</div>';
|
||||
$output .= '<div class="us-bld-editor-wrapper-controls">';
|
||||
$output .= '<a href="javascript:void(0)" class="us-bld-editor-control type_add" title="' . esc_attr( __( 'Add element into wrapper', 'us' ) ) . '"></a>';
|
||||
$output .= '<a href="javascript:void(0)" class="us-bld-editor-control type_edit" title="' . esc_attr( __( 'Edit wrapper', 'us' ) ) . '"></a>';
|
||||
$output .= '<a href="javascript:void(0)" class="us-bld-editor-control type_delete" title="' . esc_attr( __( 'Delete wrapper', 'us' ) ) . '"></a>';
|
||||
$output .= '</div>';
|
||||
$output .= '</div><!-- .us-bld-editor-wrapper -->';
|
||||
} else {
|
||||
// Handling standard single element
|
||||
$type = strtok( $elm, ':' );
|
||||
$values = isset( $data[ $elm ] ) ? $data[ $elm ] : array();
|
||||
$elm_icon = us_config( 'elements/' . $type . '.icon', $type );
|
||||
|
||||
$output .= '<div class="us-bld-editor-elm type_' . $type . '" data-id="' . esc_attr( $elm ) . '">';
|
||||
$output .= '<div class="us-bld-editor-elm-content">';
|
||||
if ( $type == 'text' AND isset( $values['text'] ) AND ( ! empty( $values['text'] ) OR ! empty( $values['icon'] ) ) ) {
|
||||
if ( ! empty( $values['icon'] ) ) {
|
||||
$output .= us_prepare_icon_tag( $values['icon'] );
|
||||
}
|
||||
$output .= strip_tags( $values['text'] );
|
||||
} elseif ( $type == 'image' ) {
|
||||
if ( ! empty( $values['img'] ) ) {
|
||||
$upload_image = usof_get_image_src( $values['img'] );
|
||||
$output .= '<img src="' . esc_attr( $upload_image[0] ) . '" />';
|
||||
} elseif ( ! empty( $elm_icon ) ) {
|
||||
$output .= '<i class="' . $elm_icon . '"></i>';
|
||||
}
|
||||
} elseif ( $type == 'menu' ) {
|
||||
if ( ! empty( $elm_icon ) ) {
|
||||
$output .= '<i class="' . $elm_icon . '"></i>';
|
||||
}
|
||||
if ( ! empty( $values['source'] ) ) {
|
||||
$nav_menus = us_get_nav_menus();
|
||||
if ( isset( $nav_menus[ $values['source'] ] ) ) {
|
||||
$output .= $nav_menus[ $values['source'] ];
|
||||
} else {
|
||||
$output .= $values['source'];
|
||||
}
|
||||
} else {
|
||||
$output .= us_translate( 'Menu' );
|
||||
}
|
||||
} elseif ( $type == 'additional_menu' ) {
|
||||
if ( ! empty( $elm_icon ) ) {
|
||||
$output .= '<i class="' . $elm_icon . '"></i>';
|
||||
}
|
||||
if ( ! empty( $values['source'] ) ) {
|
||||
$nav_menus = us_get_nav_menus();
|
||||
if ( isset( $nav_menus[ $values['source'] ] ) ) {
|
||||
$output .= $nav_menus[ $values['source'] ];
|
||||
} else {
|
||||
$output .= $values['source'];
|
||||
}
|
||||
} else {
|
||||
$output .= __( 'Links Menu', 'us' );
|
||||
}
|
||||
} elseif ( $type == 'search' AND ! empty( $values['text'] ) ) {
|
||||
if ( ! empty( $values['icon'] ) ) {
|
||||
$output .= us_prepare_icon_tag( $values['icon'] );
|
||||
}
|
||||
$output .= strip_tags( $values['text'] );
|
||||
} elseif ( $type == 'dropdown' AND isset( $values['source'] ) ) {
|
||||
if ( ! empty( $values['link_icon'] ) ) {
|
||||
$output .= us_prepare_icon_tag( $values['link_icon'] );
|
||||
}
|
||||
if ( $values['source'] == 'wpml' ) {
|
||||
$output .= 'WPML';
|
||||
} elseif ( $values['source'] == 'polylang' ) {
|
||||
$output .= 'Polylang';
|
||||
} else {
|
||||
$output .= ( ! empty( $values['link_title'] ) ) ? strip_tags( $values['link_title'] ) : __( 'Dropdown', 'us' );
|
||||
}
|
||||
} elseif ( $type == 'socials' ) {
|
||||
$socialsOutput = '';
|
||||
foreach ( $values['items'] as $key => $value ) {
|
||||
if ( $value['type'] == 'custom' AND isset( $value['icon'] ) ) {
|
||||
$socialsOutput .= us_prepare_icon_tag( $value['icon'] );
|
||||
} else {
|
||||
$socialsOutput .= '<i class="fab fa-' . $value['type'] . '"></i>';
|
||||
}
|
||||
}
|
||||
$output .= empty( $socialsOutput ) ? __( 'Social Links', 'us' ) : $socialsOutput;
|
||||
} elseif ( $type == 'btn' ) {
|
||||
if ( ! empty( $values['icon'] ) ) {
|
||||
$output .= us_prepare_icon_tag( $values['icon'] );
|
||||
}
|
||||
if ( ! empty( $values['label'] ) ) {
|
||||
$output .= strip_tags( $values['label'] );
|
||||
} elseif ( empty( $values['icon'] ) ) {
|
||||
$output .= __( 'Button', 'us' );
|
||||
}
|
||||
} elseif ( $type == 'html' ) {
|
||||
$output .= 'HTML';
|
||||
} elseif ( $type == 'cart' ) {
|
||||
if ( ! empty( $values['icon'] ) ) {
|
||||
$output .= us_prepare_icon_tag( $values['icon'] );
|
||||
} elseif ( ! empty( $elm_icon ) ) {
|
||||
$output .= '<i class="' . $elm_icon . '"></i>';
|
||||
}
|
||||
$output .= __( 'Cart', 'us' );
|
||||
} else {
|
||||
$output .= ucfirst( $type );
|
||||
}
|
||||
$output .= '</div>';
|
||||
$output .= '<div class="us-bld-editor-elm-controls">';
|
||||
$output .= '<a href="javascript:void(0)" class="us-bld-editor-control type_edit" title="' . esc_attr( __( 'Edit element', 'us' ) ) . '"></a>';
|
||||
$output .= '<a href="javascript:void(0)" class="us-bld-editor-control type_clone" title="' . esc_attr( __( 'Duplicate element', 'us' ) ) . '"></a>';
|
||||
$output .= '<a href="javascript:void(0)" class="us-bld-editor-control type_delete" title="' . esc_attr( __( 'Delete element', 'us' ) ) . '"></a>';
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
$output .= '<div class="us-bld-editor type_';
|
||||
$output .= ( us_arr_path( $value, 'default.options.orientation', 'hor' ) == 'ver' ) ? 'ver' : 'hor';
|
||||
$output .= '">';
|
||||
foreach ( array( 'top', 'middle', 'bottom' ) as $at_y ) {
|
||||
$output .= '<div class="us-bld-editor-row at_' . $at_y;
|
||||
if ( ( $at_y == 'top' OR $at_y == 'bottom' ) AND ! us_arr_path( $value, 'default.options.' . $at_y . '_show' ) ) {
|
||||
$output .= ' disabled';
|
||||
}
|
||||
$output .= '">';
|
||||
$output .= '<div class="us-bld-editor-row-h">';
|
||||
foreach ( array( 'left', 'center', 'right' ) as $at_x ) {
|
||||
$output .= '<div class="us-bld-editor-cell at_' . $at_x . '">';
|
||||
// Output inner widgets
|
||||
$output .= ushb_get_elms_placeholders( $value['default']['layout'], $value['data'], $at_y . '_' . $at_x );
|
||||
$output .= '<a href="javascript:void(0)" class="us-bld-editor-add" title="' . esc_attr( __( 'Add element', 'us' ) ) . '"></a>';
|
||||
$output .= '</div>';
|
||||
}
|
||||
$output .= '</div>';
|
||||
$output .= '</div><!-- .us-bld-editor-row -->';
|
||||
}
|
||||
|
||||
// Outputting hidden elements
|
||||
$output .= '<div class="us-bld-editor-row for_hidden">';
|
||||
$output .= '<div class="us-bld-editor-row-desc">' . __( 'Hidden Elements', 'us' ) . '</div>';
|
||||
$output .= '<div class="us-bld-editor-row-h">';
|
||||
$output .= ushb_get_elms_placeholders( $value['default']['layout'], $value['data'], 'hidden' );
|
||||
$output .= '</div>';
|
||||
$output .= '</div><!-- .us-bld-editor-row.for_hidden -->';
|
||||
$output .= '</div><!-- .us-bld-editor -->';
|
||||
|
||||
// Options
|
||||
$output .= '<div class="us-bld-options">';
|
||||
$hb_options_sections = array(
|
||||
'global' => __( 'General Header Settings', 'us' ),
|
||||
'top' => __( 'Top Area', 'us' ),
|
||||
'middle' => __( 'Main Area', 'us' ),
|
||||
'bottom' => __( 'Bottom Area', 'us' ),
|
||||
);
|
||||
|
||||
$options_values = us_arr_path( $value, 'default.options', array() );
|
||||
// Setting starting state to properly handle show_if rules
|
||||
$options_values['state'] = 'default';
|
||||
foreach ( $hb_options_sections as $hb_section => $hb_section_title ) {
|
||||
$output .= '<div class="us-bld-options-section' . ( ( $hb_section == 'global' ) ? ' active' : '' ) . '" data-id="' . $hb_section . '">';
|
||||
$output .= '<div class="us-bld-options-section-title">' . $hb_section_title . '</div>';
|
||||
$output .= '<div class="us-bld-options-section-content" style="display: ' . ( ( $hb_section == 'global' ) ? 'block' : 'none' ) . ';">';
|
||||
foreach ( us_config( 'header-settings.options.' . $hb_section, array() ) as $field_name => $fld ) {
|
||||
if ( ! isset( $fld['type'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$field_html = us_get_template(
|
||||
'vendor/usof/templates/field', array(
|
||||
'name' => $field_name,
|
||||
'id' => 'hb_opt_' . $field_name,
|
||||
'field' => $fld,
|
||||
'values' => $options_values,
|
||||
)
|
||||
);
|
||||
// Changing rows' classes to prevent auto-init of these rows as main fields
|
||||
$field_html = preg_replace( '~usof\-form\-(row|wrapper) ~', 'usof-subform-$1 ', $field_html );
|
||||
$output .= $field_html;
|
||||
}
|
||||
$output .= '</div><!-- .us-bld-options-section-content -->';
|
||||
$output .= '</div><!-- .us-bld-options-section -->';
|
||||
}
|
||||
$output .= ' </div ><!-- .us-bld-options -->';
|
||||
|
||||
$output .= '<div class="us-bld-params hidden"';
|
||||
$output .= us_pass_data_to_js(
|
||||
array(
|
||||
'navMenus' => us_get_nav_menus(),
|
||||
// TODO Default values
|
||||
)
|
||||
);
|
||||
$output .= '></div>';
|
||||
$output .= '<div class="us-bld-value hidden"' . us_pass_data_to_js( $value ) . '></div>';
|
||||
|
||||
// Elements' default values
|
||||
$elms_titles = array();
|
||||
$elms_defaults = array();
|
||||
foreach ( us_config( 'header-settings.elements', array() ) as $type ) {
|
||||
$elm = us_config( 'elements/' . $type );
|
||||
$elms_titles[ $type ] = isset( $elm['title'] ) ? $elm['title'] : $type;
|
||||
$elms_defaults[ $type ] = us_get_elm_defaults( $type, 'header' );
|
||||
}
|
||||
$output .= '<div class="us-bld-defaults hidden"' . us_pass_data_to_js( $elms_defaults ) . '></div>';
|
||||
$translations = array(
|
||||
'template_replace_confirm' => __( 'Selected template will overwrite all your current elements and settings! Are you sure want to apply it?', 'us' ),
|
||||
'orientation_change_confirm' => __( 'Are you sure want to change the header orientation? Some of your elements\' positions may be changed', 'us' ),
|
||||
'element_delete_confirm' => __( 'Are you sure want to delete the element?', 'us' ),
|
||||
'add_element' => __( 'Add element into wrapper', 'us' ),
|
||||
'edit_element' => __( 'Edit element', 'us' ),
|
||||
'clone_element' => __( 'Duplicate element', 'us' ),
|
||||
'delete_element' => __( 'Delete element', 'us' ),
|
||||
'edit_wrapper' => __( 'Edit wrapper', 'us' ),
|
||||
'delete_wrapper' => __( 'Delete wrapper', 'us' ),
|
||||
'menu' => us_translate( 'Menu' ),
|
||||
'additional_menu' => __( 'Links Menu', 'us' ),
|
||||
'dropdown' => __( 'Dropdown', 'us' ),
|
||||
'social_links' => __( 'Social Links', 'us' ),
|
||||
'button' => __( 'Button', 'us' ),
|
||||
'cart' => __( 'Cart', 'us' ),
|
||||
);
|
||||
$output .= '<div class="us-bld-translations hidden"' . us_pass_data_to_js( $translations ) . '></div>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '<div class="us-screenlock"><div>' . sprintf( __( '<a href="%s">Activate the theme</a> to unlock Header Builder', 'us' ), admin_url( 'admin.php?page=us-home#activation' ) ) . '</div></div>';
|
||||
|
||||
// List of elements that can be added
|
||||
$output .= us_get_template(
|
||||
'templates/elist', array(
|
||||
'elements' => us_config( 'header-settings.elements', array() ),
|
||||
)
|
||||
);
|
||||
|
||||
// Empty editor window for loading the elements afterwards
|
||||
$output .= us_get_template(
|
||||
'templates/ebuilder', array(
|
||||
'titles' => $elms_titles,
|
||||
'body' => '',
|
||||
)
|
||||
);
|
||||
|
||||
// Export & Import
|
||||
$output .= us_get_template(
|
||||
'templates/export_import', array(
|
||||
'title' => __( 'Header Export / Import', 'us' ),
|
||||
'text' => __( 'You can export the saved Header by copying the text inside this field. To import another Header replace the text in this field and click "Import Header" button.', 'us' ),
|
||||
'save_text' => __( 'Import Header', 'us' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Empty header templates window for loading the templates afterwards
|
||||
$output .= us_get_template(
|
||||
'templates/htemplates', array(
|
||||
'body' => '',
|
||||
)
|
||||
);
|
||||
|
||||
echo $output;
|
||||