Import legacy nurinda.co.id website
This commit is contained in:
1 parent
3f59bb9038
commit
6e21646ac4
13389 files changed
+3246690
No files matched your search
@@ -0,0 +1,203 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Output single USOF Field
|
||||
*
|
||||
* Multiple selector
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
* @var $values array Set of values for the current and relevant fields
|
||||
*/
|
||||
|
||||
if ( isset( $field['place_if'] ) AND ! $field['place_if'] ) {
|
||||
return;
|
||||
}
|
||||
if ( ! isset( $field['type'] ) ) {
|
||||
if ( WP_DEBUG ) {
|
||||
wp_die( $name . ' has no defined type' );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
$show_field = ( ! isset( $field['show_if'] ) OR usof_execute_show_if( $field['show_if'], $values ) );
|
||||
|
||||
// Options Wrapper
|
||||
if ( $field['type'] == 'wrapper_start' ) {
|
||||
$row_classes = '';
|
||||
if ( isset( $field['classes'] ) AND ! empty( $field['classes'] ) ) {
|
||||
$row_classes .= ' ' . $field['classes'];
|
||||
}
|
||||
echo '<div class="usof-form-wrapper ' . $name . $row_classes . '" data-name="' . $name . '" data-id="' . $id . '" ';
|
||||
echo 'style="display: ' . ( $show_field ? 'block' : 'none' ) . '">';
|
||||
if ( isset( $field['title'] ) AND ! empty( $field['title'] ) ) {
|
||||
echo '<div class="usof-form-wrapper-title">' . $field['title'] . '</div>';
|
||||
}
|
||||
echo '<div class="usof-form-wrapper-content">';
|
||||
if ( isset( $field['show_if'] ) AND is_array( $field['show_if'] ) AND ! empty( $field['show_if'] ) ) {
|
||||
// Showing conditions
|
||||
echo '<div class="usof-form-wrapper-showif hidden"' . us_pass_data_to_js( $field['show_if'] ) . '></div>';
|
||||
}
|
||||
|
||||
return;
|
||||
} elseif ( $field['type'] == 'wrapper_end' ) {
|
||||
echo '</div></div>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$field['std'] = isset( $field['std'] ) ? $field['std'] : NULL;
|
||||
$value = isset( $values[ $name ] ) ? $values[ $name ] : $field['std'];
|
||||
|
||||
// Options Group
|
||||
if ( $field['type'] == 'group' ) {
|
||||
global $usof_options;
|
||||
|
||||
$group_classes = ( ! empty( $field['classes'] ) ) ? ' ' . $field['classes'] : '';
|
||||
if ( isset( $field['is_accordion'] ) AND $field['is_accordion'] ) {
|
||||
$group_classes .= ' type_accordion';
|
||||
} else {
|
||||
$group_classes .= ' type_simple';
|
||||
}
|
||||
if ( isset( $field['is_sortable'] ) AND $field['is_sortable'] ) {
|
||||
$group_classes .= ' sortable';
|
||||
}
|
||||
echo '<div class="usof-form-group' . $group_classes . '" data-name="' . $name . '"';
|
||||
if ( ! empty( $field['title'] ) ) {
|
||||
echo ' data-params_title="' . rawurlencode( $field['title'] ) . '"';
|
||||
}
|
||||
echo 'style="display: ' . ( $show_field ? 'block' : 'none' ) . '">';
|
||||
echo '<div class="usof-form-group-prototype hidden">';
|
||||
us_load_template(
|
||||
'vendor/usof/templates/fields/group_param', array(
|
||||
'params_values' => array(),
|
||||
'field' => $field,
|
||||
)
|
||||
);
|
||||
echo '</div>';
|
||||
|
||||
if ( is_array( $value ) AND count( $value ) > 0 ) {
|
||||
foreach ( $value as $index => $params_values ) {
|
||||
us_load_template(
|
||||
'vendor/usof/templates/fields/group_param', array(
|
||||
'params_values' => $params_values,
|
||||
'field' => $field,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
echo '<span class="usof-form-group-add">';
|
||||
echo '<span class="usof-form-group-add-title">' . us_translate( 'Add' ) . '</span>';
|
||||
echo '<span class="usof-preloader"></span>';
|
||||
echo '</span>';
|
||||
$translations = array(
|
||||
'deleteConfirm' => __( 'Are you sure want to delete the element?', 'us' ),
|
||||
'style' => us_translate( 'Style' ),
|
||||
);
|
||||
echo '<span class="usof-form-group-translations hidden"' . us_pass_data_to_js( $translations ) . '></span>';
|
||||
if ( isset( $field['show_if'] ) AND is_array( $field['show_if'] ) AND ! empty( $field['show_if'] ) ) {
|
||||
// Showing conditions
|
||||
echo '<div class="usof-form-row-showif hidden"' . us_pass_data_to_js( $field['show_if'] ) . '></div>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$row_classes = ' type_' . $field['type'];
|
||||
if ( ! in_array(
|
||||
$field['type'], array(
|
||||
'message',
|
||||
'heading',
|
||||
)
|
||||
) AND ( ! isset( $field['classes'] ) OR strpos( $field['classes'], 'desc_' ) === FALSE ) ) {
|
||||
$row_classes .= ' desc_1';
|
||||
}
|
||||
if ( isset( $field['cols'] ) ) {
|
||||
$row_classes .= ' cols_' . $field['cols'];
|
||||
}
|
||||
if ( isset( $field['classes'] ) AND ! empty( $field['classes'] ) ) {
|
||||
$row_classes .= ' ' . $field['classes'];
|
||||
}
|
||||
|
||||
// Output option row
|
||||
echo '<div class="usof-form-row' . $row_classes . '" data-name="' . $name . '" data-id="' . $id . '" ';
|
||||
echo 'style="display: ' . ( $show_field ? 'block' : 'none' ) . '">';
|
||||
if ( isset( $field['title'] ) AND ! empty( $field['title'] ) ) {
|
||||
echo '<div class="usof-form-row-title"><span>' . $field['title'] . '</span>';
|
||||
if ( isset( $field['description'] ) AND ! empty( $field['description'] ) AND ( ! empty( $field['classes'] ) AND strpos( $field['classes'], 'desc_4' ) !== FALSE ) ) {
|
||||
echo '<div class="usof-form-row-desc">';
|
||||
echo '<div class="usof-form-row-desc-icon"></div>';
|
||||
echo '<div class="usof-form-row-desc-text">' . $field['description'] . '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
echo '<div class="usof-form-row-field"><div class="usof-form-row-control">';
|
||||
// Including the field control itself
|
||||
us_load_template(
|
||||
'vendor/usof/templates/fields/' . $field['type'], array(
|
||||
'name' => $name,
|
||||
'id' => $id,
|
||||
'field' => $field,
|
||||
'value' => $value,
|
||||
'is_metabox' => ( isset( $is_metabox ) ) ? $is_metabox : FALSE,
|
||||
)
|
||||
);
|
||||
echo '</div>';
|
||||
if ( isset( $field['description'] ) AND ! empty( $field['description'] ) AND ( empty( $field['classes'] ) OR strpos( $field['classes'], 'desc_4' ) === FALSE ) ) {
|
||||
echo '<div class="usof-form-row-desc">';
|
||||
echo '<div class="usof-form-row-desc-icon"></div>';
|
||||
echo '<div class="usof-form-row-desc-text">' . $field['description'] . '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if ( isset( $field['hints_for'] ) ) {
|
||||
|
||||
// Check if post type exist
|
||||
$post_type_obj = get_post_type_object( $field['hints_for'] );
|
||||
|
||||
if ( $post_type_obj ) {
|
||||
|
||||
$hint_text = '';
|
||||
|
||||
// Get post labels for hints
|
||||
$hints = array(
|
||||
'edit_url' => '<a href="' . admin_url( 'post.php?post={{post_id}}&action=edit' ) . '" target="_blank">{{hint}}</a>',
|
||||
// for JS
|
||||
'add' => $post_type_obj->labels->add_new,
|
||||
'edit' => __( 'Edit selected', 'us' ),
|
||||
);
|
||||
|
||||
// Count published posts
|
||||
$count_posts = wp_count_posts( $field['hints_for'] );
|
||||
$published_posts = $count_posts->publish;
|
||||
if ( $published_posts ) {
|
||||
|
||||
$edit_link = get_edit_post_link( $value );
|
||||
|
||||
// Output "Edit" link if post exists and assigned
|
||||
if ( $edit_link AND $value ) {
|
||||
$hint_text = '<a href="' . $edit_link . '" target="_blank">' . $hints['edit'] . '</a>';
|
||||
}
|
||||
|
||||
// Output "Add New" link if there are no published posts
|
||||
} else {
|
||||
$hint_text = '<a href="' . admin_url( 'post-new.php?post_type=' . $field['hints_for'] ) . '" target="_blank">' . $hints['add'] . '</a>';
|
||||
$hints['no_posts'] = TRUE;
|
||||
}
|
||||
|
||||
unset( $hints['add'] );
|
||||
|
||||
echo '<div class="usof-form-row-hint-text">' . $hint_text . '</div>';
|
||||
echo '<div class="usof-form-row-hint-json hidden"' . us_pass_data_to_js( $hints ) . '></div>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '</div>'; // .usof-form-row-field
|
||||
if ( isset( $field['show_if'] ) AND is_array( $field['show_if'] ) AND ! empty( $field['show_if'] ) ) {
|
||||
// Showing conditions
|
||||
echo '<div class="usof-form-row-showif"' . us_pass_data_to_js( $field['show_if'] ) . '></div>';
|
||||
}
|
||||
echo '</div>';
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Backup
|
||||
*
|
||||
* Store / restore options backup
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
|
||||
$backup = get_option( 'usof_backup_' . US_THEMENAME );
|
||||
|
||||
$output = '<div class="usof-backup">';
|
||||
$output .= '<div class="usof-backup-status">';
|
||||
if ( $backup AND is_array( $backup ) AND isset( $backup['time'] ) ) {
|
||||
$backup_time = strtotime( $backup['time'] ) + get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
|
||||
$output .= __( 'Last Backup', 'us' ) . ': <span>' . date_i18n( 'F j, Y - G:i T', $backup_time ) . '</span>';
|
||||
} else {
|
||||
$output .= __( 'No backups yet', 'us' );
|
||||
}
|
||||
$output .= '</div>';
|
||||
$output .= '<div class="usof-button type_backup"><span>' . __( 'Backup Options', 'us' ) . '</span>';
|
||||
$output .= '<span class="usof-preloader"></span>';
|
||||
$output .= '</div>';
|
||||
$output .= '<div class="usof-button type_restore"';
|
||||
if ( ! $backup OR ! is_array( $backup ) OR ! isset( $backup['usof_options'] ) ) {
|
||||
$output .= ' style="display: none"';
|
||||
}
|
||||
$output .= '><span class="usof-button-label">' . __( 'Restore Options', 'us' ) . '</span>';
|
||||
$output .= '<span class="usof-preloader"></span>';
|
||||
$output .= '</div>';
|
||||
$i18n = array(
|
||||
'restore_confirm' => __( 'Are you sure want to restore options from the backup?', 'us' ),
|
||||
);
|
||||
$output .= '<div class="usof-backup-i18n"' . us_pass_data_to_js( $i18n ) . '></div>';
|
||||
$output .= '</div>';
|
||||
|
||||
echo $output;
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Check Table
|
||||
*
|
||||
* Multiple selector as table
|
||||
*
|
||||
* @var $id string Field ID
|
||||
* @var $name string Field name
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['options'] array List of key => title pairs
|
||||
*
|
||||
* @var $value array List of checked keys
|
||||
*/
|
||||
|
||||
if ( ! is_array( $value ) ) {
|
||||
$value = array();
|
||||
}
|
||||
if ( isset( $is_metabox ) AND $is_metabox ) {
|
||||
$name .= '[]';
|
||||
}
|
||||
|
||||
$output = '<ul class="usof-checkbox-list">';
|
||||
foreach ( $field['options'] as $key => $option ) {
|
||||
|
||||
if ( $option['group'] != NULL ) {
|
||||
$output .= '</ul><ul class="usof-checkbox-list"><li class="usof-checkbox-list-title">' . $option['group'] . '</li>';
|
||||
}
|
||||
if ( isset( $option['apply_if'] ) AND ! $option['apply_if'] ) {
|
||||
continue;
|
||||
}
|
||||
$output .= '<li class="usof-checkbox for_' . $key . '"><label>';
|
||||
$output .= '<input type="checkbox" name="' . $name . '" value="' . esc_attr( $key ) . '"';
|
||||
if ( in_array( $key, $value ) ) {
|
||||
$output .= ' checked';
|
||||
}
|
||||
$output .= '>';
|
||||
$output .= '<span class="usof-checkbox-icon"></span>';
|
||||
$output .= '<span class="usof-checkbox-text"><span>' . $option['title'] . '</span></span>';
|
||||
$output .= '<span class="usof-checkbox-size for_js">';
|
||||
if ( isset( $option['js_size'] ) AND $option['js_size'] ) {
|
||||
$output .= $option['js_size'];
|
||||
} else {
|
||||
$output .= '-';
|
||||
}
|
||||
$output .= '</span>';
|
||||
$output .= '<span class="usof-checkbox-size for_css">';
|
||||
if ( isset( $option['css_size'] ) AND $option['css_size'] ) {
|
||||
$output .= $option['css_size'];
|
||||
} else {
|
||||
$output .= '-';
|
||||
}
|
||||
$output .= '</span>';
|
||||
$output .= '</label>';
|
||||
$output .= '<div class="usof-checkbox-description"></div>';
|
||||
$output .= '</li>';
|
||||
}
|
||||
$output .= '</ul>';
|
||||
$output .= '<div class="usof-checkbox-list-desc">' . __( 'All sizes in kilobytes', 'us' ) . '</div>';
|
||||
|
||||
echo $output;
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Checkboxes
|
||||
*
|
||||
* Multiple selector
|
||||
*
|
||||
* @var $id string Field ID
|
||||
* @var $name string Field name
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['options'] array List of key => title pairs
|
||||
*
|
||||
* @var $value array List of checked keys
|
||||
*/
|
||||
|
||||
if ( ! is_array( $value ) ) {
|
||||
$value = array();
|
||||
}
|
||||
if ( isset( $is_metabox ) AND $is_metabox ) {
|
||||
$name .= '[]';
|
||||
}
|
||||
|
||||
$output = '<ul class="usof-checkbox-list">';
|
||||
foreach ( $field['options'] as $key => $option_title ) {
|
||||
$output .= '<li class="usof-checkbox"><label>';
|
||||
$output .= '<input type="checkbox" name="' . $name . '" value="' . esc_attr( $key ) . '"';
|
||||
if ( in_array( $key, $value ) ) {
|
||||
$output .= ' checked';
|
||||
}
|
||||
$output .= '><span class="usof-checkbox-icon"></span><span class="usof-checkbox-text">' . $option_title . '</span>';
|
||||
$output .= '</label></li>';
|
||||
}
|
||||
$output .= '</ul>';
|
||||
|
||||
echo $output;
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Color
|
||||
*
|
||||
* Simple color picker
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['text'] string Field additional text
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
|
||||
if ( preg_match( '~^\#([\da-f])([\da-f])([\da-f])$~', $value, $matches ) ) {
|
||||
$value = '#' . $matches[1] . $matches[1] . $matches[2] . $matches[2] . $matches[3] . $matches[3];
|
||||
}
|
||||
|
||||
$palette = get_option( 'usof_color_palette_' . US_THEMENAME );
|
||||
if ( ! is_array( $palette ) ) {
|
||||
$palette = array();
|
||||
}
|
||||
|
||||
$gradient = strstr( $value, 'linear-gradient' ) ? ' with_gradient' : '';
|
||||
|
||||
$output = '<div class="usof-color' . $gradient . '">';
|
||||
$output .= '<div class="usof-color-preview" style="background: ' . $value . '"></div>';
|
||||
$output .= '<input class="usof-color-value" type="text" name="' . $name . '" value="' . esc_attr( $value ) . '" />';
|
||||
$output .= '<div class="usof-color-clear" title="' . us_translate( 'Clear' ) . '"></div>';
|
||||
|
||||
$output .= '<div class="usof_colpick_wrap">';
|
||||
$output .= '<div class="usof_colpick_palette">';
|
||||
|
||||
// Fill palette with default colors
|
||||
if ( empty( $palette ) ) {
|
||||
global $usof_options;
|
||||
|
||||
$options = $usof_options;
|
||||
$predefined_colors = array(
|
||||
$options['color_content_primary'],
|
||||
$options['color_content_secondary'],
|
||||
$options['color_content_heading'],
|
||||
$options['color_content_text'],
|
||||
$options['color_content_faded'],
|
||||
$options['color_content_border'],
|
||||
$options['color_content_bg_alt'],
|
||||
$options['color_content_bg'],
|
||||
);
|
||||
|
||||
update_option( 'usof_color_palette_' . US_THEMENAME, $predefined_colors );
|
||||
}
|
||||
|
||||
foreach ( $palette as $color ) {
|
||||
$output .= '<div class="usof_colpick_palette_value"><span style="background:' . $color . '" title="' . esc_attr( $color ) . '"></span><div class="usof_colpick_palette_delete" title="' . us_translate( 'Delete' ) . '"></div></div>';
|
||||
}
|
||||
$output .= '<div class="usof_colpick_palette_add" title="' . __( 'Add the current color to the palette', 'us' ) . '"></div>';
|
||||
$output .= '</div></div></div>';
|
||||
|
||||
if ( isset( $field['text'] ) AND ! empty( $field['text'] ) ) {
|
||||
$output .= '<div class="usof-color-text">' . $field['text'] . '</div>';
|
||||
}
|
||||
echo $output;
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Css
|
||||
*
|
||||
* Simple textarea field.
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
global $usof_directory_uri;
|
||||
|
||||
$output = '<div class="usof-form-row-control-ace"></div>';
|
||||
$output .= '<div class="usof-form-row-control-param"';
|
||||
$output .= us_pass_data_to_js(
|
||||
array(
|
||||
'ace_path' => $usof_directory_uri . '/js/ace/ace.js',
|
||||
'ace_ext_sarch_path' => $usof_directory_uri . '/js/ace/ext-searchbox.js',
|
||||
)
|
||||
);
|
||||
$output .= '></div>';
|
||||
$output .= '<textarea name="' . $name . '">' . esc_textarea( $value ) . '</textarea>';
|
||||
// $output .= '<div class="usof-form-row-resize"><div class="usof-form-row-resize-knob"><span></span></div></div>';
|
||||
|
||||
echo $output;
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: design_options
|
||||
*
|
||||
* Design options.
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
* @var $field['states'] array Available states: array( 'default', 'mobiles', 'tablets' )
|
||||
* @var $field['with_position'] bool Show position controls
|
||||
*
|
||||
* @var $value array Current value
|
||||
*/
|
||||
|
||||
if ( ! is_array( $value ) ) {
|
||||
$value = array();
|
||||
}
|
||||
|
||||
$directions = array( 'top', 'right', 'bottom', 'left' );
|
||||
$states = ( isset( $field['states'] ) AND is_array( $field['states'] ) ) ? $field['states'] : array( 'default', 'tablets', 'mobiles' );
|
||||
$states_titles = array(
|
||||
'default' => us_translate( 'Default' ),
|
||||
'tablets' => __( 'Tablets', 'us' ),
|
||||
'mobiles' => __( 'Mobiles', 'us' ),
|
||||
);
|
||||
$with_position = ( isset( $field['with_position'] ) AND $field['with_position'] );
|
||||
|
||||
$output = '<div class="usof-design">';
|
||||
foreach ( $states as $state ) {
|
||||
$state_title = us_arr_path( $states_titles, $state, $state );
|
||||
$output .= '<div class="usof-design-control for_' . $state . '">';
|
||||
$output .= '<div class="usof-design-control-title">' . $state_title . '</div>';
|
||||
|
||||
if ( $with_position ) {
|
||||
// Checking if position is enabled
|
||||
$pos_enabled = FALSE;
|
||||
foreach ( $directions as $part ) {
|
||||
$subname = 'position_' . $part . '_' . $state;
|
||||
if ( isset( $value[ $subname ] ) AND $value[ $subname ] !== '' ) {
|
||||
$pos_enabled = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Positioning Switcher
|
||||
$output .= '<div class="usof-switcher">';
|
||||
$output .= '<input type="hidden" name="pos_abs_' . $state . '" value="0" />';
|
||||
$output .= '<input type="checkbox" id="' . $id . '_pos_abs_' . $state . '" name="pos_abs_' . $state . '" value="1"' . ( $pos_enabled ? ' checked="checked"' : '' ) . '>';
|
||||
$output .= '<label for="' . $id . '_pos_abs_' . $state . '">';
|
||||
$output .= '<span class="usof-switcher-box"><i></i></span>';
|
||||
$output .= '<span class="usof-switcher-text">' . __( 'Absolute Positioning', 'us' ) . '</span>';
|
||||
$output .= '</label></div>';
|
||||
|
||||
// Position
|
||||
$output .= '<div class="usof-design-position' . ( $pos_enabled ? '' : ' pos_off' ) . '">';
|
||||
$output .= '<div class="usof-design-attr">Position</div>';
|
||||
foreach ( $directions as $part ) {
|
||||
$subname = 'position_' . $part . '_' . $state;
|
||||
$subvalue = isset( $value[ $subname ] ) ? $value[ $subname ] : '';
|
||||
if ( preg_match( '~^\d+$~', $subvalue ) ) {
|
||||
$subvalue = $subvalue . 'px';
|
||||
}
|
||||
$output .= '<input class="' . $part . '" type="text" name="' . esc_attr( $subname ) . '" value="' . esc_attr( $subvalue ) . '">';
|
||||
}
|
||||
}
|
||||
|
||||
// Margin
|
||||
$output .= '<div class="usof-design-margin">';
|
||||
$output .= '<div class="usof-design-attr">Margin</div>';
|
||||
foreach ( $directions as $part ) {
|
||||
$subname = 'margin_' . $part . '_' . $state;
|
||||
$subvalue = isset( $value[ $subname ] ) ? $value[ $subname ] : '';
|
||||
if ( preg_match( '~^\d+$~', $subvalue ) ) {
|
||||
$subvalue = $subvalue . 'px';
|
||||
}
|
||||
$output .= '<input class="' . $part . '" type="text" name="' . esc_attr( $subname ) . '" value="' . esc_attr( $subvalue ) . '">';
|
||||
}
|
||||
|
||||
// Border
|
||||
$output .= '<div class="usof-design-border">';
|
||||
$output .= '<div class="usof-design-attr">Border</div>';
|
||||
foreach ( $directions as $part ) {
|
||||
$subname = 'border_' . $part . '_' . $state;
|
||||
$subvalue = isset( $value[ $subname ] ) ? $value[ $subname ] : '';
|
||||
if ( preg_match( '~^\d+$~', $subvalue ) ) {
|
||||
$subvalue = $subvalue . 'px';
|
||||
}
|
||||
$output .= '<input class="' . $part . '" type="text" name="' . esc_attr( $subname ) . '" value="' . esc_attr( $subvalue ) . '">';
|
||||
}
|
||||
|
||||
// Padding
|
||||
$output .= '<div class="usof-design-padding">';
|
||||
$output .= '<div class="usof-design-attr">Padding</div>';
|
||||
foreach ( $directions as $part ) {
|
||||
$subname = 'padding_' . $part . '_' . $state;
|
||||
$subvalue = isset( $value[ $subname ] ) ? $value[ $subname ] : '';
|
||||
if ( preg_match( '~^\d+$~', $subvalue ) ) {
|
||||
$subvalue = $subvalue . 'px';
|
||||
}
|
||||
$output .= '<input class="' . $part . '" type="text" name="' . esc_attr( $subname ) . '" value="' . esc_attr( $subvalue ) . '">';
|
||||
}
|
||||
$output .= '</div>';
|
||||
|
||||
// .usof-design-border
|
||||
$output .= '</div>';
|
||||
|
||||
// .usof-design-margin
|
||||
$output .= '</div>';
|
||||
|
||||
if ( $with_position ) {
|
||||
// .usof-design-position
|
||||
$output .= '</div>';
|
||||
}
|
||||
|
||||
// .usof-design-control
|
||||
$output .= '</div>';
|
||||
}
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
echo $output;
|
||||
@@ -0,0 +1,193 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Font
|
||||
*
|
||||
* Select font
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['only_google'] bool
|
||||
* @param $field ['preview'] array
|
||||
* @param $field ['preview']['text'] string Preview text
|
||||
* @param $field ['preview']['size'] string Font size in css format
|
||||
*
|
||||
* @var $value array List of checked keys
|
||||
*/
|
||||
|
||||
global $usof_options;
|
||||
|
||||
$output = $uploaded_fonts_output = '';
|
||||
$font_value = explode( '|', $value, 2 );
|
||||
if ( ! isset( $font_value[1] ) OR empty( $font_value[1] ) ) {
|
||||
$font_value[1] = '400,700';
|
||||
}
|
||||
$font_value[1] = explode( ',', $font_value[1] );
|
||||
|
||||
// Uploaded Fonts
|
||||
$uploaded_font_families = array();
|
||||
$uploaded_fonts = us_get_option( 'uploaded_fonts', array() );
|
||||
if ( is_array( $uploaded_fonts ) AND count( $uploaded_fonts ) > 0 ) {
|
||||
$uploaded_fonts_output .= '<optgroup label="' . __( 'Uploaded Fonts', 'us' ) . '">';
|
||||
foreach ( $uploaded_fonts as $uploaded_font ) {
|
||||
$uploaded_font_name = strip_tags( $uploaded_font['name'] );
|
||||
if ( $uploaded_font_name == '' OR in_array( $uploaded_font_name, $uploaded_font_families ) OR empty( $uploaded_font['files'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$uploaded_font_families[] = $uploaded_font_name;
|
||||
$uploaded_fonts_output .= "<option class='uploaded' value='" . esc_attr( $uploaded_font_name ) . "' " . selected( $font_value[0], $uploaded_font_name, FALSE ) . '>' . $uploaded_font_name . '</option>';
|
||||
}
|
||||
$uploaded_fonts_output .= '</optgroup>';
|
||||
}
|
||||
|
||||
if ( ! isset( $web_safe_fonts ) ) {
|
||||
$web_safe_fonts = us_config( 'web-safe-fonts' );
|
||||
}
|
||||
|
||||
if ( ! isset( $google_fonts ) ) {
|
||||
$google_fonts = us_config( 'google-fonts', array() );
|
||||
if ( ! isset( $usof_options['google_fonts_included'] ) ) {
|
||||
$usof_options['google_fonts_included'] = TRUE;
|
||||
$output .= '<div class="usof-fonts-json"' . us_pass_data_to_js( $google_fonts ) . '></div>';
|
||||
}
|
||||
}
|
||||
|
||||
$output .= '<div class="usof-font">';
|
||||
|
||||
// Font preview
|
||||
$field['preview'] = isset( $field['preview'] ) ? $field['preview'] : array();
|
||||
$field['preview']['text'] = isset( $field['preview']['text'] ) ? $field['preview']['text'] : '0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
$output .= '<div class="usof-font-preview" style="background: ' . $usof_options['color_content_bg'] . ';';
|
||||
if ( isset( $field['preview']['for_heading'] ) AND $field['preview']['for_heading'] ) {
|
||||
if ( $usof_options[ $field['preview']['color_field'] ] ) {
|
||||
$output .= 'color: ' . $usof_options[ $field['preview']['color_field'] ] . ';';
|
||||
} else {
|
||||
$output .= 'color: ' . $usof_options['color_content_heading'] . ';';
|
||||
}
|
||||
} else {
|
||||
$output .= 'color: ' . $usof_options['color_content_text'] . ';';
|
||||
}
|
||||
if ( isset( $field['preview']['size_field'] ) AND ! empty( $usof_options[ $field['preview']['size_field'] ] ) ) {
|
||||
$output .= 'font-size: ' . $usof_options[ $field['preview']['size_field'] ] . ';';
|
||||
}
|
||||
if ( isset( $field['preview']['lineheight_field'] ) AND ! empty( $usof_options[ $field['preview']['lineheight_field'] ] ) ) {
|
||||
$output .= 'line-height: ' . $usof_options[ $field['preview']['lineheight_field'] ] . ';';
|
||||
}
|
||||
if ( isset( $field['preview']['letterspacing_field'] ) AND ! empty( $usof_options[ $field['preview']['letterspacing_field'] ] ) ) {
|
||||
$output .= 'letter-spacing: ' . $usof_options[ $field['preview']['letterspacing_field'] ] . ';';
|
||||
}
|
||||
if ( isset( $field['preview']['transform_field'] ) AND ! empty( $usof_options[ $field['preview']['transform_field'] ] ) ) {
|
||||
if ( in_array( 'uppercase', $usof_options[ $field['preview']['transform_field'] ] ) ) {
|
||||
$output .= 'text-transform: uppercase;';
|
||||
}
|
||||
if ( in_array( 'italic', $usof_options[ $field['preview']['transform_field'] ] ) ) {
|
||||
$output .= 'font-style: italic;';
|
||||
}
|
||||
}
|
||||
if ( isset( $field['preview']['weight_field'] ) AND ! empty( $usof_options[ $field['preview']['weight_field'] ] ) ) {
|
||||
$output .= 'font-weight: ' . $usof_options[ $field['preview']['weight_field'] ] . ';';
|
||||
} elseif ( count( $font_value[1] ) > 0 ) {
|
||||
$output .= 'font-weight: ' . intval( $font_value[1][0] ) . ';';
|
||||
}
|
||||
$output .= '"><div>' . $field['preview']['text'] . '</div></div>';
|
||||
|
||||
$output .= '<input type="hidden" name="' . $name . '" value="' . esc_attr( $value ) . '" />';
|
||||
$output .= '<select>';
|
||||
|
||||
// Output if 'only_google' param is not set
|
||||
if ( ! isset( $field['only_google'] ) OR ! $field['only_google'] ) {
|
||||
$output .= '<option value="none" ' . selected( $font_value[0], 'none', FALSE ) . '>' . __( 'No font specified', 'us' ) . '</option>';
|
||||
|
||||
if ( isset( $field['preview']['get_h1'] ) AND $field['preview']['get_h1'] ) {
|
||||
$output .= '<option value="get_h1" ' . selected( $font_value[0], 'get_h1', FALSE ) . '>' . __( 'As in Heading 1', 'us' ) . '</option>';
|
||||
}
|
||||
|
||||
// Uploaded Fonts
|
||||
$output .= $uploaded_fonts_output;
|
||||
|
||||
// Web safe fonts
|
||||
$output .= '<optgroup label="' . __( 'Web safe font combinations (do not need to be loaded)', 'us' ) . '">';
|
||||
foreach ( $web_safe_fonts as $font_name ) {
|
||||
$output .= '<option class="websafe" value="' . esc_attr( $font_name ) . '" ' . selected( $font_value[0], $font_name, FALSE ) . '>' . $font_name . '</option>';
|
||||
}
|
||||
$output .= '</optgroup>';
|
||||
}
|
||||
// Google Fonts
|
||||
$output .= '<optgroup label="' . __( 'Google Fonts (loaded from Google servers)', 'us' ) . '">';
|
||||
foreach ( $google_fonts as $font_name => &$tmp_font_value ) {
|
||||
if ( $font_name == '' OR in_array( $font_name, $uploaded_font_families ) ) {
|
||||
continue;
|
||||
}
|
||||
$output .= '<option value="' . esc_attr( $font_name ) . '"' . selected( $font_value[0], $font_name, FALSE ) . '>' . $font_name . '</option>';
|
||||
}
|
||||
$output .= '</optgroup>';
|
||||
|
||||
$output .= '</select>';
|
||||
|
||||
// Font weights
|
||||
if ( ! isset( $font_weights ) ) {
|
||||
$font_weights = array(
|
||||
'100' => '100 ' . __( 'thin', 'us' ),
|
||||
'100italic' => '100 ' . __( 'thin', 'us' ) . ' <i>' . __( 'italic', 'us' ) . '</i>',
|
||||
'200' => '200 ' . __( 'extra-light', 'us' ),
|
||||
'200italic' => '200 ' . __( 'extra-light', 'us' ) . ' <i>' . __( 'italic', 'us' ) . '</i>',
|
||||
'300' => '300 ' . __( 'light', 'us' ),
|
||||
'300italic' => '300 ' . __( 'light', 'us' ) . ' <i>' . __( 'italic', 'us' ) . '</i>',
|
||||
'400' => '400 ' . __( 'normal', 'us' ),
|
||||
'400italic' => '400 ' . __( 'normal', 'us' ) . ' <i>' . __( 'italic', 'us' ) . '</i>',
|
||||
'500' => '500 ' . __( 'medium', 'us' ),
|
||||
'500italic' => '500 ' . __( 'medium', 'us' ) . ' <i>' . __( 'italic', 'us' ) . '</i>',
|
||||
'600' => '600 ' . __( 'semi-bold', 'us' ),
|
||||
'600italic' => '600 ' . __( 'semi-bold', 'us' ) . ' <i>' . __( 'italic', 'us' ) . '</i>',
|
||||
'700' => '700 ' . __( 'bold', 'us' ),
|
||||
'700italic' => '700 ' . __( 'bold', 'us' ) . ' <i>' . __( 'italic', 'us' ) . '</i>',
|
||||
'800' => '800 ' . __( 'extra-bold', 'us' ),
|
||||
'800italic' => '800 ' . __( 'extra-bold', 'us' ) . ' <i>' . __( 'italic', 'us' ) . '</i>',
|
||||
'900' => '900 ' . __( 'ultra-bold', 'us' ),
|
||||
'900italic' => '900 ' . __( 'ultra-bold', 'us' ) . ' <i>' . __( 'italic', 'us' ) . '</i>',
|
||||
);
|
||||
}
|
||||
$show_weights = (array) us_config( 'google-fonts.' . $font_value[0] . '.variants', array() );
|
||||
|
||||
$output .= '<ul class="usof-checkbox-list">';
|
||||
foreach ( $font_weights as $font_weight => $font_title ) {
|
||||
$output .= '<li class="usof-checkbox' . ( in_array( $font_weight, $show_weights ) ? '' : ' hidden' ) . '" data-value="' . $font_weight . '">';
|
||||
$output .= '<label class="' . ( in_array( $font_weight, $show_weights ) ? '' : 'hidden' ) . '">';
|
||||
$output .= '<input type="checkbox" value="' . $font_weight . '"';
|
||||
$output .= ( in_array( $font_weight, $font_value[1] ) ? ' checked' : '' );
|
||||
$output .= '>';
|
||||
$output .= '<span class="usof-checkbox-icon"></span><span class="usof-checkbox-text">';
|
||||
$output .= $font_title . '</span></label></li>';
|
||||
}
|
||||
$output .= '</ul>';
|
||||
|
||||
$font_style_fields_data = array();
|
||||
if ( isset( $field['preview']['color_field'] ) ) {
|
||||
$font_style_fields_data['colorField'] = $field['preview']['color_field'];
|
||||
}
|
||||
if ( isset( $field['preview']['size_field'] ) ) {
|
||||
$font_style_fields_data['sizeField'] = $field['preview']['size_field'];
|
||||
}
|
||||
if ( isset( $field['preview']['lineheight_field'] ) ) {
|
||||
$font_style_fields_data['lineheightField'] = $field['preview']['lineheight_field'];
|
||||
}
|
||||
if ( isset( $field['preview']['weight_field'] ) ) {
|
||||
$font_style_fields_data['weightField'] = $field['preview']['weight_field'];
|
||||
}
|
||||
if ( isset( $field['preview']['letterspacing_field'] ) ) {
|
||||
$font_style_fields_data['letterspacingField'] = $field['preview']['letterspacing_field'];
|
||||
}
|
||||
if ( isset( $field['preview']['transform_field'] ) ) {
|
||||
$font_style_fields_data['transformField'] = $field['preview']['transform_field'];
|
||||
}
|
||||
|
||||
$output .= '<div class="usof-font-style-fields-json"' . us_pass_data_to_js( $font_style_fields_data ) . '></div>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
echo $output;
|
||||
+265
@@ -0,0 +1,265 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: grid_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_grid_settings( $value );
|
||||
|
||||
$output = '<div class="us-bld" data-ajaxurl="' . esc_attr( admin_url( 'admin-ajax.php' ) ) . '">';
|
||||
|
||||
// States
|
||||
$output .= '<div class="us-bld-states" style="display: none;">';
|
||||
$output .= '<div class="us-bld-state for_default active">' . us_translate( 'Default' ) . '</div>';
|
||||
$output .= '</div>';
|
||||
|
||||
// Workspace
|
||||
$output .= '<div class="us-bld-workspace for_default">';
|
||||
|
||||
global $us_gb_post_date_types, $us_gb_product_field_types;
|
||||
$us_gb_post_date_types = array(
|
||||
'published' => __( 'Date of creation', 'us' ),
|
||||
'modified' => __( 'Date of update', 'us' ),
|
||||
);
|
||||
// Get the values of "type" param of "Product data" element
|
||||
$us_gb_product_field_types = us_config( 'elements/product_field.params.type.options', array() );
|
||||
|
||||
// Editor
|
||||
if ( ! function_exists( 'usgb_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 usgb_get_elms_placeholders( &$layout, &$data, $place ) {
|
||||
$output = '';
|
||||
if ( ! isset( $layout[ $place ] ) OR ! is_array( $layout[ $place ] ) ) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
foreach ( $layout[ $place ] as $elm ) {
|
||||
// Checking if the element has absolute position (= at least one design options position is not empty)
|
||||
$is_abs = FALSE;
|
||||
foreach ( array( 'left', 'top', 'right', 'bottom' ) as $direction ) {
|
||||
$direction_value = us_arr_path( $data, $elm . '.design_options.position_' . $direction . '_default', '' );
|
||||
if ( $direction_value !== '' ) {
|
||||
$is_abs = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( substr( $elm, 1, 7 ) == 'wrapper' ) {
|
||||
$output .= '<div class="us-bld-editor-wrapper type_' . ( ( $elm[0] == 'h' ) ? 'horizontal' : 'vertical' );
|
||||
$output .= $is_abs ? ' pos_abs' : '';
|
||||
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 .= usgb_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, ':' );
|
||||
$elm_title = us_config( 'elements/' . $type . '.title', $type );
|
||||
$values = isset( $data[ $elm ] ) ? $data[ $elm ] : array();
|
||||
|
||||
$output .= '<div class="us-bld-editor-elm type_' . $type;
|
||||
$output .= $is_abs ? ' pos_abs' : '';
|
||||
$output .= '" data-id="' . esc_attr( $elm ) . '">';
|
||||
$output .= '<div class="us-bld-editor-elm-content">';
|
||||
if ( ! empty( $values['icon'] ) ) {
|
||||
$output .= us_prepare_icon_tag( $values['icon'] );
|
||||
}
|
||||
if ( $type == 'text' AND isset( $values['text'] ) AND ( ! empty( $values['text'] ) OR ! empty( $values['icon'] ) ) ) {
|
||||
$output .= strip_tags( $values['text'] );
|
||||
} 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 == 'post_taxonomy' AND isset( $values['taxonomy_name'] ) ) {
|
||||
$taxonomies_options = us_get_taxonomies();
|
||||
$output .= us_arr_path( $taxonomies_options, $values['taxonomy_name'], $elm_title );
|
||||
} elseif ( $type == 'post_custom_field' AND isset( $values['key'] ) ) {
|
||||
$custom_fields_options = us_get_custom_fields();
|
||||
$output .= us_arr_path( $custom_fields_options, $values['key'], $elm_title );
|
||||
if ( $values['key'] === 'custom' ) {
|
||||
$output .= ': ' . strip_tags( us_arr_path( $values, 'custom_key', '' ) );
|
||||
}
|
||||
} elseif ( $type == 'post_date' AND isset( $values['type'] ) ) {
|
||||
global $us_gb_post_date_types;
|
||||
$output .= us_arr_path( $us_gb_post_date_types, $values['type'], $elm_title );
|
||||
} elseif ( $type == 'product_field' AND isset( $values['type'] ) ) {
|
||||
global $us_gb_product_field_types;
|
||||
$output .= us_arr_path( $us_gb_product_field_types, $values['type'], $elm_title );
|
||||
if ( $values['type'] == 'sale_badge' AND ! empty ( $values['sale_text'] ) ) {
|
||||
$output .= ': "' . strip_tags( $values['sale_text'] ) . '"';
|
||||
}
|
||||
} else {
|
||||
$output .= $elm_title;
|
||||
}
|
||||
$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">';
|
||||
$output .= '<div class="us-bld-editor-row at_middle">';
|
||||
$output .= '<div class="us-bld-editor-row-h">';
|
||||
$output .= '<div class="us-bld-editor-cell at_center">';
|
||||
// Output inner widgets
|
||||
// keeping middle_center for compatibility
|
||||
$output .= usgb_get_elms_placeholders( $value['default']['layout'], $value['data'], 'middle_center' );
|
||||
$output .= '<a href="javascript:void(0)" class="us-bld-editor-add" title="' . esc_attr( __( 'Add element', 'us' ) ) . '"></a>';
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
$output .= '</div><!-- .us-bld-editor -->';
|
||||
|
||||
// Options
|
||||
$output .= '<div class="us-bld-options">';
|
||||
$hb_options_sections = array(
|
||||
'global' => __( 'Grid Layout Settings', 'us' ),
|
||||
// 'hover' => __( 'On hover', '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( 'grid-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>';
|
||||
$output .= '</div>';
|
||||
}
|
||||
$output .= ' </div ><!-- .us-bld-options -->';
|
||||
|
||||
$output .= '<div class="us-bld-params hidden"';
|
||||
$output .= us_pass_data_to_js(
|
||||
array(
|
||||
'navMenus' => us_get_nav_menus(),
|
||||
)
|
||||
);
|
||||
$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( 'grid-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, 'grid' );
|
||||
}
|
||||
$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' ),
|
||||
'posts_taxonomies' => us_get_taxonomies(),
|
||||
'custom_fields_options' => us_get_custom_fields(),
|
||||
'post_date_types' => $us_gb_post_date_types,
|
||||
'product_field_types' => $us_gb_product_field_types,
|
||||
);
|
||||
|
||||
// Setting elements titles for translations
|
||||
$translations['elms_titles'] = array();
|
||||
foreach ( us_config( 'grid-settings.elements', array() ) as $elm ) {
|
||||
$elm_config = us_config( 'elements/' . $elm );
|
||||
$translations['elms_titles'][ $elm ] = us_arr_path( $elm_config, 'title', $elm );
|
||||
}
|
||||
|
||||
$output .= '<div class="us-bld-translations hidden"' . us_pass_data_to_js( $translations ) . '></div>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
// List of elements that can be added
|
||||
$output .= us_get_template(
|
||||
'templates/elist', array(
|
||||
'elements' => us_config( 'grid-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' => __( 'Export / Import', 'us' ),
|
||||
'text' => __( 'To import another Grid Layout replace the text in this field and click "Import" button.', 'us' ),
|
||||
'save_text' => __( 'Import Grid Layout', 'us' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Empty grid layout templates window for loading the templates afterwards
|
||||
$output .= us_get_template(
|
||||
'templates/gtemplates', array(
|
||||
'body' => '',
|
||||
)
|
||||
);
|
||||
echo $output;
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Grid Layout Select
|
||||
*
|
||||
* Drop-down selector field.
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
|
||||
// Get Grid Layouts
|
||||
$templates_config = us_config( 'grid-templates', array(), TRUE );
|
||||
|
||||
$custom_layouts = array_flip( us_get_posts_titles_for( 'us_grid_layout' ) );
|
||||
|
||||
$output = '<div class="usof-grid-layout-select">';
|
||||
$output .= '<select name="' . $name . '">';
|
||||
$output .= '<optgroup label="' . __( 'Grid Layouts', 'us' ) . '">';
|
||||
foreach ( $custom_layouts as $title => $id ) {
|
||||
$output .= '<option value="' . $id . '"';
|
||||
if ( $value == $id ) {
|
||||
$output .= ' selected="selected"';
|
||||
}
|
||||
$output .= ' data-edit-url="' . admin_url( '/post.php?post=' . $id . '&action=edit' ) . '">' . $title . '</option>';
|
||||
}
|
||||
$current_tmpl_group = '';
|
||||
foreach ( $templates_config as $template_name => $template ) {
|
||||
if ( ! empty( $template['group'] ) AND $current_tmpl_group != $template['group'] ) {
|
||||
$current_tmpl_group = $template['group'];
|
||||
$output .= '</optgroup>';
|
||||
$output .= '<optgroup label="' . $template['group'] . '">';
|
||||
}
|
||||
$output .= '<option value="' . $template_name . '"';
|
||||
if ( $value == $template_name ) {
|
||||
$output .= ' selected="selected"';
|
||||
}
|
||||
$output .= '>' . $template['title'] . '</option>';
|
||||
}
|
||||
$output .= '</optgroup>';
|
||||
$output .= '</select>';
|
||||
$output .= '<div class="us-grid-layout-desc-edit">';
|
||||
$output .= sprintf( _x( '%sEdit selected%s or %screate a new one%s.', 'Grid Layout', 'us' ), '<a href="#" class="edit-link" target="_blank">', '</a>', '<a href="' . admin_url() . 'post-new.php?post_type=us_grid_layout" target="_blank">', '</a>' );
|
||||
$output .= '</div>';
|
||||
$output .= '<div class="us-grid-layout-desc-add">';
|
||||
$output .= '<a href="' . admin_url() . 'post-new.php?post_type=us_grid_layout" target="_blank">' . __( 'Add Grid Layout', 'us' ) . '</a>.';
|
||||
$output .= '</div></div>';
|
||||
|
||||
echo $output;
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Group
|
||||
*
|
||||
* Grouped options
|
||||
*
|
||||
* @var $field array Group options
|
||||
* @var $params_values array Group values
|
||||
*
|
||||
*/
|
||||
|
||||
$param_content_styles = '';
|
||||
$output = '<div class="usof-form-group-item">';
|
||||
|
||||
// Output Title block when Accordion type is set
|
||||
if ( isset( $field[ 'is_accordion' ] ) AND $field[ 'is_accordion' ] ) {
|
||||
$param_title = ( ! empty( $field['title'] ) ) ? $field['title'] : '';
|
||||
foreach ( $field['params'] as $param_name => $param ) {
|
||||
if ( strpos( $param_title, '{{' . $param_name . '}}' ) !== FALSE ) {
|
||||
$param_value = isset( $params_values[$param_name] ) ? $params_values[$param_name] : $field['params'][$param_name]['std'];
|
||||
$param_value = esc_attr( trim( $param_value ) );
|
||||
$param_title = str_replace( '{{' . $param_name . '}}', $param_value, $param_title );
|
||||
}
|
||||
}
|
||||
$output .= '<div class="usof-form-group-item-title">';
|
||||
|
||||
// Output Button Preview when class "for_btns" is set
|
||||
if ( isset( $field['classes'] ) AND strpos( $field['classes'], 'for_btns' ) !== FALSE ) {
|
||||
$output .= '<div class="usof-btn-preview hov_fade">';
|
||||
$output .= '<div class="usof-btn">';
|
||||
$output .= '<div class="usof-btn-before"></div>';
|
||||
$output .= '<span class="usof-btn-label">' . $param_title . '</span>';
|
||||
$output .= '<div class="usof-btn-after"></div>';
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
} else {
|
||||
$output .= $param_title;
|
||||
}
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
$param_content_styles = ' style="display:none;"';
|
||||
}
|
||||
|
||||
$output .= '<div class="usof-form-group-item-content"' . $param_content_styles . '>';
|
||||
ob_start();
|
||||
foreach ( $field['params'] as $param_name => $param ) {
|
||||
us_load_template(
|
||||
'vendor/usof/templates/field', array(
|
||||
'name' => $param_name,
|
||||
'id' => 'usof_' . $param_name,
|
||||
'field' => $param,
|
||||
'values' => $params_values,
|
||||
)
|
||||
);
|
||||
}
|
||||
$output .= ob_get_clean();
|
||||
$output .= '</div>';
|
||||
$output .= '<div class="usof-form-group-item-controls">';
|
||||
if ( isset( $field['is_sortable'] ) AND $field['is_sortable'] ) {
|
||||
$output .= '<div class="usof-control-move" title="' . us_translate( 'Move' ) . '"></div>';
|
||||
}
|
||||
$output .= '<div class="usof-control-delete" title="' . us_translate( 'Delete' ) . '"></div>';
|
||||
$output .= '</div></div>';
|
||||
|
||||
echo $output;
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Heading
|
||||
*
|
||||
* Simple heading.
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Html
|
||||
*
|
||||
* Simple textarea field.
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['encoded'] bool Value is encoded
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
global $usof_directory_uri;
|
||||
|
||||
$data = array(
|
||||
'ace_path' => $usof_directory_uri . '/js/ace/ace.js',
|
||||
'ace_ext_sarch_path' => $usof_directory_uri . '/js/ace/ext-searchbox.js',
|
||||
);
|
||||
if ( isset( $field['encoded'] ) AND $field['encoded'] ) {
|
||||
$data['encoded'] = 1;
|
||||
}
|
||||
|
||||
$output = '<div class="usof-form-row-control-ace"></div>';
|
||||
$output .= '<div class="usof-form-row-control-param"';
|
||||
$output .= us_pass_data_to_js($data);
|
||||
$output .= '></div>';
|
||||
|
||||
$output .= '<textarea name="' . $name . '">' . esc_textarea( $value ) . '</textarea>';
|
||||
// $output .= '<div class="usof-form-row-resize"><div class="usof-form-row-resize-knob"><span></span></div></div>';
|
||||
|
||||
echo $output;
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Icon
|
||||
*
|
||||
* Icon field with preview
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['text'] string Field additional text
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
|
||||
$icon_sets = us_config( 'icon-sets', array() );
|
||||
|
||||
reset( $icon_sets );
|
||||
$value = trim( $value );
|
||||
if ( ! preg_match( '/(fas|far|fal|fab|material)\|[a-z0-9-]/i', $value ) ) {
|
||||
$value = $field['std'];
|
||||
}
|
||||
$select_value = $input_value = '';
|
||||
$value_arr = explode('|', $value);
|
||||
if ( count( $value_arr ) == 2 ) {
|
||||
$select_value = $value_arr[0];
|
||||
$input_value = $value_arr[1];
|
||||
}
|
||||
if ( empty( $select_value ) ) {
|
||||
$select_value = key( $icon_sets );
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="us-icon">
|
||||
<input name="<?php echo esc_attr( $name ); ?>" class="us-icon-value" type="hidden" value="<?php echo esc_attr( $value ); ?>">
|
||||
<div class="usof-select">
|
||||
<select name="icon_set" class="us-icon-select">
|
||||
<?php foreach ( $icon_sets as $set_slug => $set_info ) { ?>
|
||||
<option value="<?php echo $set_slug ?>"<?php if ( $select_value == $set_slug ) echo ' selected="selected"'; ?> data-info-url="<?php echo $set_info['set_url'] ?>"><?php echo $set_info['set_name'] ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="us-icon-preview">
|
||||
<?php echo ( $icon_preview_html = us_prepare_icon_tag( $value ) ) ? $icon_preview_html : '<i class="material-icons"></i>'; ?>
|
||||
</div>
|
||||
<div class="us-icon-input">
|
||||
<input name="icon_name" class="us-icon-text" type="text" value="<?php echo $input_value; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="us-icon-desc">
|
||||
<?php echo '<a class="us-icon-set-link" href="' . $icon_sets[$select_value]['set_url'] . '" target="_blank">' . __( 'Enter icon name from the list', 'us' ) . '</a>. ' . __( 'Examples:', 'us' ) . ' <span class="usof-example">star</span>, <span class="usof-example">edit</span>, <span class="usof-example">code</span>' ?>
|
||||
</div>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Images
|
||||
*
|
||||
* Radiobutton-like toggler of images
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['options'] array Associative array of value => image
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
|
||||
global $us_template_directory_uri;
|
||||
|
||||
$output = '<ul class="usof-imgradio">';
|
||||
foreach ( $field['options'] as $key => $img_url ) {
|
||||
$output .= '<li class="usof-imgradio-item">';
|
||||
$output .= '<input type="radio" id="' . $id . '_' . $key . '" name="' . $name . '"' . checked( $value, $key, FALSE ) . ' value="' . esc_attr( $key ) . '">';
|
||||
$output .= '<label for="' . $id . '_' . $key . '"><img src="' . trailingslashit( $us_template_directory_uri ) . $img_url . '.png" srcset="' . trailingslashit( $us_template_directory_uri ) . $img_url . '-2x.png 2x" alt="' . $key . '"></label>';
|
||||
$output .= '</li>';
|
||||
}
|
||||
$output .= '</ul>';
|
||||
|
||||
echo $output;
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Link
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['text'] string Field additional text
|
||||
*
|
||||
* @var $value string Current value
|
||||
*
|
||||
* @param $value ['url'] string Link URL
|
||||
* @param $value ['target'] string Link Target
|
||||
*/
|
||||
|
||||
if ( ! is_array( $value ) ) {
|
||||
$value = array(
|
||||
'url' => is_string( $value ) ? $value : '',
|
||||
);
|
||||
}
|
||||
if ( ! isset( $value['url'] ) ) {
|
||||
$value['url'] = '';
|
||||
}
|
||||
if ( ! isset( $value['target'] ) ) {
|
||||
$value['target'] = '';
|
||||
}
|
||||
$output = '<input type="hidden" name="' . $name . '" value="' . esc_attr( json_encode( $value ) ) . '" />';
|
||||
$output .= '<input type="text" value="' . esc_attr( $value['url'] ) . '"';
|
||||
if ( isset( $field['placeholder'] ) AND ! empty( $field['placeholder'] ) ) {
|
||||
$output .= ' placeholder="' . esc_attr( $field['placeholder'] ) . '"';
|
||||
}
|
||||
$output .= ' />';
|
||||
|
||||
$output .= '<div class="usof-checkbox">';
|
||||
$output .= '<label>';
|
||||
$output .= '<input type="checkbox"';
|
||||
if ( $value['target'] == '_blank' ) {
|
||||
$output .= ' checked';
|
||||
}
|
||||
$output .= '>';
|
||||
$output .= '<span class="usof-checkbox-icon"></span><span class="usof-checkbox-text">' . us_translate( 'Open link in a new tab' ) . '</span>';
|
||||
$output .= '</label>';
|
||||
$output .= '</div>';
|
||||
|
||||
echo $output;
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Info
|
||||
*
|
||||
* Information message
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
*/
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Radio
|
||||
*
|
||||
* Radio buttons selector
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['options'] array List of key => title pairs
|
||||
*
|
||||
* @var $value array List of checked keys
|
||||
*/
|
||||
|
||||
$output = '<ul class="usof-radio-list">';
|
||||
foreach ( $field['options'] as $key => $option_title ) {
|
||||
$output .= '<li class="usof-radio">';
|
||||
$output .= '<input type="radio" id="' . $id . '_' . $key . '" name="' . $name . '" value="' . esc_attr( $key ) . '"';
|
||||
$output .= checked( $value, $key, FALSE );
|
||||
$output .= '><label for="' . $id . '_' . $key . '">' . $option_title . '</label>';
|
||||
$output .= '</li>';
|
||||
}
|
||||
$output .= '</ul>';
|
||||
|
||||
echo $output;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Transfer
|
||||
*
|
||||
* Transfer theme options data
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
|
||||
$output = '<div class="usof-reset">';
|
||||
$output .= '<div class="usof-button type_reset"><span>' . __( 'Reset Options', 'us' ) . '</span>';
|
||||
$output .= '<span class="usof-preloader"></span></div>';
|
||||
$output .= '</div>';
|
||||
|
||||
$i18n = array(
|
||||
'reset_confirm' => __( 'Are you sure want to reset all the options to default values?', 'us' ),
|
||||
'reset_complete' => __( 'Options were reset', 'us' ),
|
||||
);
|
||||
$output .= '<div class="usof-form-row-control-i18n"' . us_pass_data_to_js( $i18n ) . '></div>';
|
||||
|
||||
echo $output;
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Select
|
||||
*
|
||||
* Drop-down selector field.
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['options'] array List of value => title pairs
|
||||
* @param $field ['is_advanced'] bool apply select2 script
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
|
||||
$output = '<div class="usof-select';
|
||||
if ( isset( $field['is_advanced'] ) AND $field['is_advanced'] ) {
|
||||
$output .= ' type_advanced';
|
||||
}
|
||||
$output .= '">';
|
||||
|
||||
$output .= '<select name="' . $name . '"';
|
||||
if ( isset( $field['is_advanced'] ) AND $field['is_advanced'] ) {
|
||||
$output .= ' class="advanced"';
|
||||
}
|
||||
$output .= '>';
|
||||
|
||||
$is_first_optgroup = TRUE;
|
||||
foreach ( $field['options'] as $key => $option ) {
|
||||
if ( is_array( $option ) AND isset( $option['optgroup'] ) AND $option['optgroup'] ) {
|
||||
if ( ! $is_first_optgroup ) {
|
||||
$output .= '</optgroup>';
|
||||
}
|
||||
$output .= '<optgroup label="' . esc_attr( $option['title'] ) . '">';
|
||||
$is_first_optgroup = FALSE;
|
||||
|
||||
} else {
|
||||
$output .= '<option value="' . esc_attr( $key ) . '"' . selected( $value, $key, FALSE ) . '>' . $option . '</option>';
|
||||
}
|
||||
}
|
||||
if ( ! $is_first_optgroup ) {
|
||||
$output .= '</optgroup>';
|
||||
}
|
||||
|
||||
$output .= '</select>';
|
||||
$output .= '</div>';
|
||||
|
||||
echo $output;
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Slider
|
||||
*
|
||||
* Slider-selector of the integer value within some range.
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['options'] array with "min", "max", "step" values
|
||||
* @param $field ['std'] string Default value
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
|
||||
// Set fallback values when "options" param is not set in config
|
||||
if ( ! isset( $field['options'] ) ) {
|
||||
$field['options'] = array(
|
||||
'px' => array(
|
||||
'min' => 0,
|
||||
'max' => 100,
|
||||
'step' => 1,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Get the first unit name from config
|
||||
$unit_keys = array_keys( $field['options'] );
|
||||
$first_unit = isset( $unit_keys[0] ) ? $unit_keys[0] : '';
|
||||
|
||||
$output = '<div class="usof-slider';
|
||||
if ( count( $field['options'] ) > 1 ) {
|
||||
$output .= ' with_units'; // add class when more then 1 units in config
|
||||
}
|
||||
$output .= '">';
|
||||
$output .= '<div class="usof-slider-selector">';
|
||||
|
||||
// Prepare value for regex
|
||||
$value = esc_attr( trim( $value ) );
|
||||
$value = str_replace( ',', '.', $value );
|
||||
|
||||
// Cut the string to get a unit
|
||||
$units_expression = implode( '|', array_map( 'preg_quote', $unit_keys ) );
|
||||
preg_match( '#^(-?\d+)(\.)?(\d+)?(' . $units_expression . ')?$#i', $value, $matches );
|
||||
|
||||
if ( isset( $matches[4] ) ) {
|
||||
$current_unit = $matches[4];
|
||||
$valueOutput = $value;
|
||||
} else {
|
||||
$current_unit = $first_unit;
|
||||
$valueOutput = $value . $first_unit;
|
||||
}
|
||||
|
||||
$output .= '<input type="text" name="' . $name . '" value="' . $valueOutput . '" />';
|
||||
|
||||
// Define current unit params
|
||||
$max = isset( $field['options'][ $current_unit ]['max'] ) ? $field['options'][ $current_unit ]['max'] : 100;
|
||||
$min = isset( $field['options'][ $current_unit ]['min'] ) ? $field['options'][ $current_unit ]['min'] : 0;
|
||||
$step = isset( $field['options'][ $current_unit ]['step'] ) ? $field['options'][ $current_unit ]['step'] : 1;
|
||||
|
||||
// Output units selection based on config
|
||||
$output .= '<div class="usof-slider-selector-units"';
|
||||
$output .= ' data-units_expression="' . $units_expression . '"';
|
||||
$output .= ' data-unit="' . $current_unit . '"';
|
||||
$output .= ' data-max="' . $max . '"';
|
||||
$output .= ' data-min="' . $min . '"';
|
||||
$output .= ' data-step="' . $step . '"';
|
||||
$output .= '>';
|
||||
foreach ( $field['options'] as $unit => $values ) {
|
||||
$data_atts = ' data-unit="' . $unit . '"';
|
||||
$data_atts .= ' data-max="' . ( isset( $values['max'] ) ? $values['max'] : 100 ) . '"';
|
||||
$data_atts .= ' data-min="' . ( isset( $values['min'] ) ? $values['min'] : 0 ) . '"';
|
||||
$data_atts .= ' data-step="' . ( isset( $values['step'] ) ? $values['step'] : 1 ) . '"';
|
||||
|
||||
$output .= '<div class="usof-slider-selector-unit"' . $data_atts . '>';
|
||||
if ( empty( $unit ) ) {
|
||||
$output .= '<i>' . __( 'No units', 'us' ) . '</i>'; // case for empty unit, like in "line-height" option
|
||||
} else {
|
||||
$output .= $unit;
|
||||
}
|
||||
$output .= '</div>';
|
||||
}
|
||||
$output .= '</div></div>';
|
||||
|
||||
// Calculate slider range offset in percents based on current "min" and "max" values
|
||||
$offset_direction = ( is_rtl() ) ? 'right' : 'left';
|
||||
$float_value = floatval( $value );
|
||||
|
||||
if ( $max <= $min ) {
|
||||
$offset = 100;
|
||||
} else {
|
||||
if ( $float_value < $min ) {
|
||||
$offset = 0;
|
||||
} elseif ( $float_value >= $max ) {
|
||||
$offset = 100;
|
||||
} else {
|
||||
$offset = ( min( $max, max( $min, $float_value ) ) - $min ) * 100 / ( $max - $min );
|
||||
}
|
||||
}
|
||||
|
||||
$output .= '<div class="usof-slider-box"><div class="usof-slider-box-h">';
|
||||
$output .= '<div class="usof-slider-range" style="' . $offset_direction . ':' . $offset . '%;">';
|
||||
$output .= '<div class="usof-slider-runner" draggable="true"></div>';
|
||||
$output .= '</div></div></div>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
echo $output;
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Select Scheme
|
||||
*
|
||||
* Drop-down selector field.
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
|
||||
// Could already be defined in parent function
|
||||
if ( ! isset( $color_schemes ) ) {
|
||||
$color_schemes = us_config( 'style-schemes' );
|
||||
}
|
||||
if ( ! isset( $custom_color_schemes ) ) {
|
||||
$custom_color_schemes = get_option( 'usof_style_schemes_' . US_THEMENAME );
|
||||
if ( ! is_array( $custom_color_schemes ) ) {
|
||||
$custom_color_schemes = array();
|
||||
}
|
||||
}
|
||||
|
||||
// Reverse Custom schemes order to make last added item first
|
||||
$custom_color_schemes = array_reverse( $custom_color_schemes, TRUE );
|
||||
|
||||
// Window title and close control
|
||||
$output = '<div class="us-bld-window-title">' . __( 'Color Schemes', 'us' ) . '</div>';
|
||||
$output .= '<div class="us-bld-window-closer" title="' . us_translate( 'Close' ) . '"></div>';
|
||||
|
||||
$output .= '<div class="usof-schemes">';
|
||||
|
||||
// Save as new controls
|
||||
$output .= '<div class="usof-schemes-controls">';
|
||||
$output .= '<div class="usof-schemes-text">' . __( 'Save current colors as', 'us' ) . '</div>';
|
||||
$output .= '<input type="text" id="scheme_name" value="" placeholder="' . __( 'Color Scheme Name', 'us' ) . '"/>';
|
||||
$output .= '<button id="save_new_scheme" class="usof-button" disabled type="button">';
|
||||
$output .= '<span>' . _x( 'Save as new', 'color scheme', 'us' ) . '</span>';
|
||||
$output .= '<span class="usof-preloader"></span>';
|
||||
$output .= '</button>';
|
||||
$output .= '</div>';
|
||||
|
||||
// Schemes list
|
||||
$output .= '<ul class="usof-schemes-list">';
|
||||
|
||||
// Custom schemes
|
||||
foreach ( $custom_color_schemes as $key => &$scheme ) {
|
||||
$output .= '<li class="usof-schemes-item type_custom" data-id="' . $key . '">';
|
||||
$output .= usof_color_scheme_preview( $scheme );
|
||||
// Overwrite btn
|
||||
$output .= '<div class="usof-schemes-item-save" title="' . us_translate( 'Save' ) . '"></div>';
|
||||
// Delete btn
|
||||
$output .= '<div class="usof-schemes-item-delete" title="' . us_translate( 'Delete' ) . '"></div>';
|
||||
$output .= '</li>';
|
||||
}
|
||||
// Predefined schemes
|
||||
foreach ( $color_schemes as $key => &$scheme ) {
|
||||
$output .= '<li class="usof-schemes-item" data-id="' . $key . '">';
|
||||
$output .= usof_color_scheme_preview( $scheme );
|
||||
$output .= '</li>';
|
||||
}
|
||||
|
||||
$output .= '</ul>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
$first_color_scheme = array_shift( $color_schemes );
|
||||
$color_scheme_colors = array_keys( $first_color_scheme['values'] );
|
||||
$output .= '<div class="usof-form-row-control-colors-json hidden"' . us_pass_data_to_js( $color_scheme_colors ) . '></div>';
|
||||
|
||||
$i18n = array(
|
||||
'delete_confirm' => __( 'Are you sure want to delete the element?', 'us' ),
|
||||
);
|
||||
$output .= '<div class="usof-form-row-control-i18n hidden"' . us_pass_data_to_js( $i18n ) . '></div>';
|
||||
|
||||
echo $output;
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Switch
|
||||
*
|
||||
* On-off switcher
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['options'] array Array of two key => title pairs
|
||||
* @param $field ['text'] array Additional text to show right near the switcher
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
|
||||
if ( ! isset( $field['options'] ) OR empty( $field['options'] ) ) {
|
||||
$field['options'] = array(
|
||||
TRUE => 'On',
|
||||
FALSE => 'Off',
|
||||
);
|
||||
}
|
||||
$field_keys = array_keys( $field['options'] );
|
||||
if ( count( $field_keys ) < 2 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$output = '<div class="usof-switcher">';
|
||||
$output .= '<input type="hidden" name="' . $name . '" value="' . esc_attr( $field_keys[1] ) . '" />';
|
||||
$output .= '<input type="checkbox" id="' . $id . '" name="' . $name . '"' . checked( $value, $field_keys[0], FALSE ) . ' value="' . esc_attr( $field_keys[0] ) . '">';
|
||||
$output .= '<label for="' . $id . '">';
|
||||
$output .= '<span class="usof-switcher-box"><i></i></span>';
|
||||
if ( isset( $field['switch_text'] ) AND ! empty( $field['switch_text'] ) ) {
|
||||
$output .= '<span class="usof-switcher-text">' . $field['switch_text'] . '</span>';
|
||||
}
|
||||
$output .= '</label></div>';
|
||||
|
||||
echo $output;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Text
|
||||
*
|
||||
* Simple text field.
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['placeholder'] string Field placeholder
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
|
||||
$output = '<input type="text" name="' . $name . '" value="' . esc_attr( $value ) . '"';
|
||||
if ( isset( $field['placeholder'] ) AND ! empty( $field['placeholder'] ) ) {
|
||||
$output .= ' placeholder="' . esc_attr( $field['placeholder'] ) . '"';
|
||||
}
|
||||
$output .= ' />';
|
||||
|
||||
echo $output;
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Textarea
|
||||
*
|
||||
* Simple textarea field.
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['placeholder'] string Field placeholder
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
|
||||
$output = '<textarea name="' . $name . '"';
|
||||
if ( isset( $field['placeholder'] ) AND ! empty( $field['placeholder'] ) ) {
|
||||
$output .= ' placeholder="' . esc_attr( $field['placeholder'] ) . '"';
|
||||
}
|
||||
$output .= '>' . esc_textarea( $value ) . '</textarea>';
|
||||
|
||||
echo $output;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Transfer
|
||||
*
|
||||
* Transfer theme options data
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
*
|
||||
* @var $value string Current value
|
||||
*/
|
||||
|
||||
$output = '<div class="usof-transfer">';
|
||||
$output .= '<textarea></textarea>';
|
||||
$output .= '<div class="usof-button type_import"><span>' . _x( 'Import Options', 'verb', 'us' ) . '</span>';
|
||||
$output .= '<span class="usof-preloader"></span>';
|
||||
$output .= '</div>';
|
||||
$translations = array(
|
||||
'importError' => __( 'Wrong import data format', 'us' ),
|
||||
'importSuccess' => __( 'Options imported', 'us' ),
|
||||
);
|
||||
$output .= '<div class="usof-transfer-translations"' . us_pass_data_to_js( $translations ) . '></div>';
|
||||
$output .= '</div>';
|
||||
|
||||
echo $output;
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
|
||||
|
||||
/**
|
||||
* Theme Options Field: Upload
|
||||
*
|
||||
* Upload some file with the specified settings.
|
||||
*
|
||||
* @var $name string Field name
|
||||
* @var $id string Field ID
|
||||
* @var $field array Field options
|
||||
*
|
||||
* @param $field ['title'] string Field title
|
||||
* @param $field ['description'] string Field title
|
||||
* @param $field ['button_label'] string Upload Button label
|
||||
* @param $field ['preview_type'] string 'image' / 'text'
|
||||
* @param $field ['is_multiple'] bool
|
||||
*
|
||||
* @var $value mixed Either full path to the file, or ID from WordPress media uploads
|
||||
*/
|
||||
|
||||
$field['preview_type'] = isset( $field['preview_type'] ) ? $field['preview_type'] : 'image';
|
||||
$field['is_multiple'] = isset( $field['is_multiple'] ) ? $field['is_multiple'] : FALSE;
|
||||
$field['button_label'] = isset( $field['button_label'] ) ? $field['button_label'] : us_translate( 'Set image' );
|
||||
|
||||
$upload_file = '';
|
||||
if ( $field['preview_type'] == 'image' ) {
|
||||
if ( ! empty( $value ) ) {
|
||||
$upload_file = usof_get_image_src( $value, 'medium' );
|
||||
}
|
||||
} elseif ( $field['preview_type'] == 'text' ) {
|
||||
$files = explode( ',', $value );
|
||||
$upload_file = array();
|
||||
foreach ( $files as $file ) {
|
||||
$url = wp_get_attachment_url( $file );
|
||||
if ( $url ) {
|
||||
$upload_file[] = $url;
|
||||
}
|
||||
}
|
||||
if ( count( $upload_file ) == 0 ) {
|
||||
$upload_file = FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$control_buttons = '<div class="usof-upload-controls">';
|
||||
$control_buttons .= '<a class="usof-button type_change" href="javascript:void(0)"><span>' . us_translate( 'Change' ) . '</span></a>';
|
||||
$control_buttons .= '<a class="usof-button type_remove" href="javascript:void(0)"><span>' . us_translate( 'Remove' ) . '</span></a>';
|
||||
$control_buttons .= '</div>';
|
||||
|
||||
$output = '<div class="usof-upload preview_' . $field['preview_type'];
|
||||
if ( $field['is_multiple'] ) {
|
||||
$output .= ' is_multiple';
|
||||
}
|
||||
$output .= '">';
|
||||
$output .= '<input type="hidden" name="' . $name . '" value="' . $value . '">';
|
||||
|
||||
$output .= '<button class="usof-button type_upload" type="button"' . ( $upload_file ? ' style="display:none;"' : '' ) . '>';
|
||||
$output .= '<span class="usof-button-label">' . $field['button_label'] . '</span>';
|
||||
$output .= '</button>';
|
||||
|
||||
$output .= '<div class="usof-upload-preview"' . ( $upload_file ? '' : ' style="display:none;"' ) . '>';
|
||||
if ( $field['preview_type'] == 'image' ) {
|
||||
$output .= '<div class="usof-preloader"></div>';
|
||||
if ( $upload_file ) {
|
||||
$output .= '<img src="' . esc_attr( $upload_file[0] ) . '" alt="preview" />';
|
||||
} else {
|
||||
$output .= '<img src="" alt="preview" />';
|
||||
}
|
||||
$output .= $control_buttons;
|
||||
} elseif ( $field['preview_type'] == 'text' ) {
|
||||
$output .= '<div class="usof-upload-file">';
|
||||
if ( $upload_file ) {
|
||||
foreach ( $upload_file as $file ) {
|
||||
$output .= '<span>' . basename( $file ) . '</span>';
|
||||
}
|
||||
}
|
||||
$output .= '</div>';
|
||||
$output .= $control_buttons;
|
||||
}
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
|
||||
echo $output;
|
||||
|
||||
unset( $upload_file );
|
||||
Reference in new issue
Block a user