Skip to content

Commit

Permalink
Version 1.4.18
Browse files Browse the repository at this point in the history
  • Loading branch information
themefuse committed Nov 29, 2014
1 parent a94c394 commit 918f90f
Show file tree
Hide file tree
Showing 15 changed files with 104 additions and 82 deletions.
2 changes: 1 addition & 1 deletion scratch-parent/framework/bootstrap-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Convert to Unix style directory separators
*/
function fw_fix_path($path) {
return str_replace(array('//', '\\'), array('/', '/'), $path);
return untrailingslashit( str_replace(array('//', '\\'), array('/', '/'), $path) );
}

/** Child theme related functions */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class _FW_Extension_Sidebars_Config
'front_page_slug' => array(
'order_option' => 1,
'name' => 'Pages with Front-Page template',
'check_priority' => 'last' // type string 'first' | 'last'
'conditional_tag' => array(
'callback' => 'is_page_template',
'params' => array('page-templates/front-page.php')
Expand Down Expand Up @@ -82,23 +83,28 @@ private function get_config_defaults() {
'conditional_tags' => array(
'is_front_page' => array(
'name' => __('Home Page', 'fw'),
'order_option' => 3
'order_option' => 3,
'check_priority' => 'first'
),
'is_search' => array(
'name' => __('Search Page', 'fw'),
'order_option' => 2
'order_option' => 2,
'check_priority' => 'last'
),
'is_404' => array(
'name' => __('404 Page', 'fw'),
'order_option' => 4
'order_option' => 4,
'check_priority' => 'last'
),
'is_author' => array(
'name' => __('Author Page', 'fw'),
'order_option' => 1
'order_option' => 1,
'check_priority' => 'last'
),
'is_archive' => array(
'name' => __('Archive Page','fw'),
'order_option' => 5
'order_option' => 5,
'check_priority' => 'last'
)
)
)
Expand Down Expand Up @@ -205,7 +211,7 @@ private function get_post_types() {
*/
public function get_conditional_tags_labels($with_ordering = false)
{
$cts = fw_akg('select_options/conditional_tags', $this->config, array());
$cts = $this->get_conditional_tags();

if ($with_ordering) {
uasort($cts, array($this, 'conditional_tag_cmp'));
Expand Down Expand Up @@ -388,9 +394,18 @@ public function has_position($position)
return (isset($this->config['sidebar_positions'][$position]) and is_array($this->config['sidebar_positions'][$position]));
}

public function get_conditional_tags()
public function get_conditional_tags($priority = null)
{
return fw_akg('select_options/conditional_tags', $this->config, array());
$conditional_tags = apply_filters('fw_ext_sidebars_post_types', fw_akg('select_options/conditional_tags', $this->config, array()) ) ;

if ($priority) {
foreach($conditional_tags as $key => $conditional_tag) {
if ($conditional_tag['check_priority'] != $priority) {
unset($conditional_tags[$key]);
}
}
}
return $conditional_tags;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ public function render_sidebar($color)
*/
public function get_current_page_preset()
{
// check if current_page_preset doesn't get before
if ($this->current_page_preset !== null) {
return $this->current_page_preset;

$result = $this->check_conditional_tags('first');
if ($result) {
return $result;
}

if (is_singular()){
Expand All @@ -84,7 +85,7 @@ public function get_current_page_preset()

$result = $this->get_preset_sidebars($data);
if ( $result )
return $result;
return $result;
}

if (is_category()) {
Expand All @@ -97,20 +98,6 @@ public function get_current_page_preset()
return $result;
}

//was disabled from config
{
if (is_tag()) {
$term_obj = get_term_by('slug', get_query_var('tag'), 'post_tag');
$data['type'] = $this->config->get_type_by_prefix(_FW_Extension_Sidebars_Config::TAXONOMIES_PREFIX);
$data['sub_type'] = $term_obj->taxonomy;
$data['id'] = $term_obj->term_id;

$result = $this->get_preset_sidebars($data);
if ( $result )
return $result;
}
}

if (is_tax()) {
$term_obj = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
$data['type'] = $this->config->get_type_by_prefix(_FW_Extension_Sidebars_Config::TAXONOMIES_PREFIX);
Expand All @@ -122,7 +109,19 @@ public function get_current_page_preset()
return $result;
}

$conditional_tags = $this->config->get_conditional_tags();
$result = $this->check_conditional_tags('last');
if ($result) {
return $result;
}

$data['type'] = $this->config->get_type_by_prefix(_FW_Extension_Sidebars_Config::DEFAULT_PREFIX);
$data['sub_type'] = _FW_Extension_Sidebars_Config::DEFAULT_SUB_TYPE;
$result = $this->get_preset_sidebars($data); //return preset default for all pages
return $result;
}

private function check_conditional_tags($priority) {
$conditional_tags = $this->config->get_conditional_tags($priority);

foreach($conditional_tags as $key => $cond_tag)
{
Expand Down Expand Up @@ -164,11 +163,6 @@ public function get_current_page_preset()
}

}

$data['type'] = $this->config->get_type_by_prefix(_FW_Extension_Sidebars_Config::DEFAULT_PREFIX);
$data['sub_type'] = _FW_Extension_Sidebars_Config::DEFAULT_SUB_TYPE;
$result = $this->get_preset_sidebars($data); //return preset default for all pages
return $result;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions scratch-parent/framework/helpers/class-fw-wp-filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ final public static function real_path_to_filesystem_path($path) {

$path = fw_fix_path($path);

$real_abspath = untrailingslashit(fw_fix_path(ABSPATH));
$wp_filesystem_abspath = untrailingslashit($wp_filesystem->abspath());
$real_abspath = fw_fix_path(ABSPATH);
$wp_filesystem_abspath = fw_fix_path($wp_filesystem->abspath());
$relative_path = preg_replace('/^'. preg_quote($real_abspath, '/') .'/', '', $path);

return $wp_filesystem_abspath . $relative_path;
Expand All @@ -114,8 +114,8 @@ final public static function filesystem_path_to_real_path($wp_filesystem_path) {

$wp_filesystem_path = fw_fix_path($wp_filesystem_path);

$real_abspath = untrailingslashit(fw_fix_path(ABSPATH));
$wp_filesystem_abspath = untrailingslashit($wp_filesystem->abspath());
$real_abspath = fw_fix_path(ABSPATH);
$wp_filesystem_abspath = fw_fix_path($wp_filesystem->abspath());
$relative_path = preg_replace('/^'. preg_quote($wp_filesystem_abspath, '/') .'/', '', $wp_filesystem_path);

return $real_abspath . $relative_path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ protected function _render($id, $option, $data)
unset($collected);
}

$option['attr']['data-for-js'] = base64_encode(json_encode(array(
$option['attr']['data-for-js'] = json_encode(array(
'options' => $this->transform_options($box_options),
'template' => $option['template'],
)));
));

return fw_render_view(fw_get_framework_directory('/includes/option-types/'. $this->get_type() .'/view.php'), array(
'id' => $id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ jQuery(document).ready(function ($) {
return;
}

var data = JSON.parse(atob(
var data = JSON.parse(
$box.closest(optionTypeClass).attr('data-for-js')
));
);

data.template = $.trim(data.template);

Expand Down Expand Up @@ -221,8 +221,8 @@ jQuery(document).ready(function ($) {
var increment = parseInt($button.attr('data-increment'));

var $newBox = $(
$option.find('.default-box-template:first').attr('data-template')
.split('###-addable-box-increment-###').join(String(increment))
$option.find('> .default-box-template').attr('data-template')
.split( $button.attr('data-increment-placeholder') ).join( String(increment) )
);

$button.attr('data-increment', increment + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<?php
echo fw()->backend->render_box(
$data['id_prefix'] . $id .'-'. $i .'-box',
'͏&nbsp;',
'&nbsp;',
ob_get_clean(),
array(
'html_after_title' => $controls_html,
Expand Down Expand Up @@ -69,17 +69,17 @@
$values = array();

// must contain characters that will remain the same after htmlspecialchars()
$increment_template = '###-addable-box-increment-###';
$increment_placeholder = '###-addable-box-increment-'. fw_rand_md5() .'-###';

echo fw_htmlspecialchars(
'<div class="fw-option-box" data-name-prefix="'. fw_htmlspecialchars($data['name_prefix'] .'['. $id .']['. $increment_template .']') .'">'.
'<div class="fw-option-box" data-name-prefix="'. fw_htmlspecialchars($data['name_prefix'] .'['. $id .']['. $increment_placeholder .']') .'">'.
fw()->backend->render_box(
$data['id_prefix'] . $id .'-'. $increment_template .'-box',
'͏&nbsp;',
$data['id_prefix'] . $id .'-'. $increment_placeholder .'-box',
'&nbsp;',
'<div class="fw-option-box-options fw-force-xs">'.
fw()->backend->render_options($box_options, $values, array(
'id_prefix' => $data['id_prefix'] . $id .'-'. $increment_template .'-',
'name_prefix' => $data['name_prefix'] .'['. $id .']['. $increment_template .']',
'id_prefix' => $data['id_prefix'] . $id .'-'. $increment_placeholder .'-',
'name_prefix' => $data['name_prefix'] .'['. $id .']['. $increment_placeholder .']',
)).
'</div>',
array(
Expand All @@ -96,7 +96,8 @@
'onclick' => 'return false;',
'class' => 'button fw-option-boxes-add-button',
'data-increment' => ++$i,
'data-limit' => intval($option['limit'])
'data-increment-placeholder' => $increment_placeholder,
'data-limit' => intval($option['limit']),
), __('Add', 'fw'));
?>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jQuery(document).ready(function ($) {

var $newOption = $(
$option.find('.default-addable-option-template:first').attr('data-template')
.split('###-addable-option-increment-###').join(String(increment))
.split( $button.attr('data-increment-placeholder') ).join( String(increment) )
);

// animation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
$values = array();

// must contain characters that will remain the same after htmlspecialchars()
$increment_template = '###-addable-option-increment-###';
$increment_placeholder = '###-addable-option-increment-'. fw_rand_md5() .'-###';

echo fw_htmlspecialchars(
'<tr class="fw-option-type-addable-option-option">
Expand All @@ -66,7 +66,7 @@
</td>
<td class="td-option fw-force-xs">'.
fw()->backend->option_type($option['option']['type'])->render(
$increment_template,
$increment_placeholder,
$option['option'],
array(
'id_prefix' => $data['id_prefix'] . $id .'--option-',
Expand All @@ -80,9 +80,14 @@
</tr>'
);
?>">
<div>
<button type="button" class="button fw-option-type-addable-option-add" onclick="return false;" data-increment="<?php echo $i ?>"><?php
_e('Add', 'fw')
?></button>
<div><?php
echo fw_html_tag('button', array(
'type' => 'button',
'class' => 'button fw-option-type-addable-option-add',
'onclick' => 'return false;',
'data-increment' => $i,
'data-increment-placeholder' => $increment_placeholder,
), __('Add', 'fw'));
?>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ protected function _render($id, $option, $data)
{
unset($option['attr']['name'], $option['attr']['value']);

$option['attr']['data-for-js'] = base64_encode(json_encode(array(
$option['attr']['data-for-js'] = json_encode(array(
'title' => empty($option['popup-title']) ? $option['label'] : $option['popup-title'],
'options' => $this->transform_options($option['popup-options']),
'template' => $option['template']
)));
));

$sortable_image = fw_get_framework_directory_uri('/static/img/sort-vertically.png');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
return $defaultItem.clone().removeClass('default');
}
},
data = JSON.parse(atob(nodes.$optionWrapper.attr('data-for-js'))),
data = JSON.parse(nodes.$optionWrapper.attr('data-for-js')),
utils = {
modal: new fw.OptionsModal({
title: data.title,
Expand Down Expand Up @@ -59,7 +59,8 @@
$clonedInput = $clonedItem.find('.input-wrapper');

var $inputTemplate = $(
$.trim($clonedInput.html()).split('###-addable-popup-increment-###').join(utils.countItems())
$.trim($clonedInput.html())
.split( nodes.$addButton.attr('data-increment-placeholder') ).join(utils.countItems())
);
$inputTemplate.attr('value', JSON.stringify(values));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
$attr = $option['attr'];

// must contain characters that will remain the same after htmlspecialchars()
$increment_template = '###-addable-popup-increment-###';
$increment_placeholder = '###-addable-popup-increment-'. fw_rand_md5() .'-###';
?>
<div <?php echo fw_attr_to_html($attr); ?>>

<div class="items-wrapper">
<div class="item default">
<div class="input-wrapper">
<?php echo fw()->backend->option_type('hidden')->render('', array('value' => '[]'), array(
'id_prefix' => $data['id_prefix'] . $id . '-' . $increment_template . '-',
'id_prefix' => $data['id_prefix'] . $id . '-' . $increment_placeholder . '-',
'name_prefix' => $data['name_prefix'] . '[' . $id . ']',
));?>
</div>
Expand All @@ -41,6 +41,13 @@
<?php endforeach; ?>
</div>
<!--<div class="dashicons dashicons-plus add-new-item"></div>-->
<button type="button" class="button add-new-item" onclick="return false;">Add</button>
<?php
echo fw_html_tag('button', array(
'type' => 'button',
'class' => 'button add-new-item',
'onclick' => 'return false;',
'data-increment-placeholder' => $increment_placeholder,
), __('Add', 'fw'));
?>
</div>

Loading

0 comments on commit 918f90f

Please sign in to comment.