public function __construct($args) { parent::__construct(array('screen' => 'fw-ext-update-extensions-update')); $this->_extensions = $args['extensions']; $this->_table_columns = array('cb' => '<input type="checkbox" />', 'details' => fw_html_tag('a', array('href' => '#', 'onclick' => "jQuery(this).closest('tr').find('input[type=\"checkbox\"]:first').trigger('click'); return false;"), __('Select All', 'fw'))); $this->_table_columns_count = count($this->_table_columns); }
/** * @internal */ protected function _render($id, $option, $data) { // this js contains custom changes wp_enqueue_script('fw-option-' . $this->get_type() . '-image-picker', fw_get_framework_directory_uri('/includes/option-types/' . $this->get_type() . '/static/js/image-picker/image-picker.js'), array(), fw()->manifest->get_version(), true); wp_enqueue_style('fw-option-' . $this->get_type(), fw_get_framework_directory_uri('/includes/option-types/' . $this->get_type() . '/static/css/styles.css'), array('qtip'), fw()->manifest->get_version()); wp_enqueue_script('fw-option-' . $this->get_type(), fw_get_framework_directory_uri('/includes/option-types/' . $this->get_type() . '/static/js/scripts.js'), array('fw-events', 'qtip'), fw()->manifest->get_version(), true); $wrapper_attr = array('id' => $option['attr']['id'], 'class' => $option['attr']['class']); foreach ($wrapper_attr as $attr_name => $attr_val) { unset($option['attr'][$attr_name]); } $option['value'] = (string) $data['value']; unset($option['attr']['multiple']); /** * pre loads images on page load * * fixes glitch with preview: * * hover first time - show wrong because image not loaded and has no height/width and cannot detect correctly popup position * * hover second time - show correctly */ $pre_load_images_html = ''; $html = ''; $html .= '<select ' . fw_attr_to_html($option['attr']) . '>'; if (!empty($option['blank']) and $option['blank'] === true) { $html .= '<option value=""></option>'; } foreach ($option['choices'] as $key => $choice) { $attr = array('value' => $key); if ($option['value'] == $key) { $attr['selected'] = 'selected'; } if (is_string($choice)) { // is 'http://.../small.png' $choice = array('small' => array('src' => $choice)); } if (is_string($choice['small'])) { // is 'http://.../small.png' $choice['small'] = array('src' => $choice['small']); } $attr['data-small-img-attr'] = json_encode($choice['small']); // required by image-picker plugin $attr['data-img-src'] = $choice['small']['src']; if (!empty($choice['large'])) { if (is_string($choice['large'])) { // is 'http://.../large.png' $choice['large'] = array('src' => $choice['large']); } $attr['data-large-img-attr'] = json_encode($choice['large']); $pre_load_images_html .= fw_html_tag('img', array('src' => $choice['large']['src'])); } if (!empty($choice['data'])) { // used in js events $attr['data-extra-data'] = json_encode($choice['data']); } $html .= fw_html_tag('option', $attr, fw_htmlspecialchars(isset($choice['label']) ? $choice['label'] : '')); } $html .= '</select>'; return fw_html_tag('div', $wrapper_attr, $html . '<div class="pre-loaded-images"><br/><br/>' . $pre_load_images_html . '</div>'); }
public function after($data = array()) { $update_actions = array('extensions_page' => fw_html_tag('a', array('href' => fw_akg('extensions_page_link', $data, '#'), 'title' => __('Go to extensions page', 'fw'), 'target' => '_parent'), __('Return to Extensions page', 'fw'))); $this->feedback(implode(' | ', (array) $update_actions)); if ($this->result) { // used for popup ajax form submit result $this->feedback('<span success></span>'); } }
/** * @internal */ protected function _render($id, $option, $data) { $wrapper_attr = array('id' => $option['attr']['id'], 'class' => $option['attr']['class']); foreach ($wrapper_attr as $attr_name => $attr_val) { unset($option['attr'][$attr_name]); } $option['value'] = (string) $data['value']; unset($option['attr']['multiple']); /** * pre loads images on page load * * fixes glitch with preview: * * hover first time - show wrong because image not loaded and has no height/width and cannot detect correctly popup position * * hover second time - show correctly */ $pre_load_images_html = ''; $html = ''; $html .= '<select ' . fw_attr_to_html($option['attr']) . '>'; if (!empty($option['blank']) and $option['blank'] === true) { $html .= '<option value=""></option>'; } foreach ($option['choices'] as $key => $choice) { $attr = array('value' => $key); if ($option['value'] == $key) { $attr['selected'] = 'selected'; } if (is_string($choice)) { // is 'http://.../small.png' $choice = array('small' => array('src' => $choice)); } if (is_string($choice['small'])) { // is 'http://.../small.png' $choice['small'] = array('src' => $choice['small']); } $attr['data-small-img-attr'] = json_encode($choice['small']); // required by image-picker plugin $attr['data-img-src'] = $choice['small']['src']; if (!empty($choice['large'])) { if (is_string($choice['large'])) { // is 'http://.../large.png' $choice['large'] = array('src' => $choice['large']); } $attr['data-large-img-attr'] = json_encode($choice['large']); $pre_load_images_html .= fw_html_tag('img', array('src' => $choice['large']['src'])); } if (!empty($choice['data'])) { // used in js events $attr['data-extra-data'] = json_encode($choice['data']); } $html .= fw_html_tag('option', $attr, fw_htmlspecialchars(isset($choice['label']) ? $choice['label'] : '')); } $html .= '</select>'; return fw_html_tag('div', $wrapper_attr, $html . '<div class="pre-loaded-images"><br/><br/>' . $pre_load_images_html . '</div>'); }
public function after() { $update_actions = array('updates_page' => fw_html_tag('a', array('href' => self_admin_url('update-core.php'), 'title' => __('Go to updates page', 'fw'), 'target' => '_parent'), __('Return to Updates page', 'fw'))); /** * Filter the list of action links available following extensions update. * @param array $update_actions Array of plugin action links. */ $update_actions = apply_filters('fw_ext_update_extensions_complete_actions', $update_actions); if (!empty($update_actions)) { $this->feedback(implode(' | ', (array) $update_actions)); } }
/** * @param string $icon A string that is meant to be an icon (an image, a font icon class, or something else) * @return string */ function fw_ext_builder_string_to_icon_html($icon) { if (preg_match('/\\.(png|jpg|jpeg|gif|svg|webp)$/', $icon)) { // http://.../image.png return fw_html_tag('img', array('class' => 'fw-ext-builder-icon', 'src' => $icon)); } elseif (preg_match('/^[a-zA-Z0-9\\-_ ]+$/', $icon)) { // 'font-icon font-icon-class' return fw_html_tag('span', array('class' => 'fw-ext-builder-icon ' . trim($icon)), true); } else { // can't detect. maybe it's raw html '<span ...' return $icon; } }
protected function _render($containers, $values, $data) { $html = ''; $defaults = $this->get_defaults(); foreach ($containers as $id => &$option) { $attr = $option['attr']; $attr['data-modal-title'] = $option['title']; if (in_array($option['modal-size'], array('small', 'medium', 'large'))) { $attr['data-modal-size'] = $option['modal-size']; } else { $attr['data-modal-size'] = $defaults['modal-size']; } $html .= '<div ' . fw_attr_to_html($attr) . '>' . '<p class="popup-button-wrapper">' . fw_html_tag('button', array('type' => 'button', 'class' => 'button button-secondary popup-button'), $option['title']) . '</p>' . (empty($option['desc']) ? '' : '<div class="popup-desc">' . $option['desc'] . '</div>') . '<div class="popup-options fw-hidden">' . fw()->backend->render_options($option['options'], $values, $data) . '</div>' . '</div>'; } return $html; }
/** * @internal */ protected function _render($id, $option, $data) { if (is_null($data['value'])) { $data['value'] = $this->get_value_from_input($option, null); } $input_attr = array('name' => $option['attr']['name'], 'id' => $option['attr']['id'] . '--checkbox', 'data-switch-left' => $option['left-choice']['label'], 'data-switch-right' => $option['right-choice']['label']); foreach (array('left', 'right') as $value_type) { $input_attr['data-switch-' . $value_type . '-value-json'] = json_encode($option[$value_type . '-choice']['value']); } if ($checked = $data['value'] === $option['right-choice']['value']) { $input_attr['checked'] = 'checked'; // right choice means checked } $input_attr['value'] = json_encode($option[($checked ? 'right' : 'left') . '-choice']['value']); unset($option['attr']['name'], $option['attr']['value'], $option['attr']['checked'], $option['attr']['type']); return '<div ' . fw_attr_to_html($option['attr']) . '>' . '<!-- note: value is json encoded, if want to use it in js, do: var val = JSON.parse($input.val()); -->' . ($checked ? '' : fw_html_tag('input', array('type' => 'hidden', 'name' => $input_attr['name'], 'value' => $input_attr['data-switch-left-value-json']))) . '<input type="checkbox" ' . fw_attr_to_html($input_attr) . ' />' . '</div>'; }
public function get_html() { ob_start(); /** * This call will write something in _WP_Editors::$qt_settings and * _WP_Editors::$mce_settings. Let's keep them there, we'll rewrite any * data we need on the client side anyway later. */ wp_editor($this->get_value_for_render(), $this->editor_id, $this->get_settings()); $editor_html = ob_get_contents(); ob_end_clean(); $option = $this->option; unset($option['attr']['name'], $option['attr']['value']); $preinit_data = $this->get_preinit_data_for_editor(); $option['attr']['data-fw-editor-id'] = $this->editor_id; $option['attr']['data-fw-mce-settings'] = json_encode($preinit_data['mce_settings']); $option['attr']['data-fw-qt-settings'] = json_encode($preinit_data['qt_settings']); $option['attr']['data-size'] = $option['size']; $option['attr']['data-mode'] = in_array($option['editor_type'], array('html', 'tinymce')) ? $option['editor_type'] : false; return fw_html_tag('div', $option['attr'], $editor_html); }
public final function get_thumbnails() { $data = $this->get_thumbnails_data(); $thumbs = array(); foreach ($data as $item) { $item = array_merge(array('tab' => '~', 'title' => '', 'description' => ''), $item); $data_str = ''; if (!empty($item['data']) && is_array($item['data'])) { foreach ($item['data'] as $key => $value) { $data_str .= "data-{$key}='{$value}' "; } $data_str = substr($data_str, 0, -1); } $hover_tooltip = $item['description'] ? "data-hover-tip='{$item['description']}'" : ''; $inner_classes = 'no-image'; $image_html = ''; if (isset($item['image'])) { // convert old key to new $item['icon'] = $item['image']; unset($item['image']); } if (isset($item['icon'])) { $inner_classes = ''; if (version_compare(fw_ext('builder')->manifest->get_version(), '1.1.12', '<')) { $image_html = fw_html_tag('img', array('src' => $item['icon'])); } else { $image_html = fw_ext_builder_string_to_icon_html($item['icon']); } } if (!isset($thumbs[$item['title']])) { $thumbs[$item['title']] = array('tab' => $item['tab'], 'html' => "<div class='inner {$inner_classes}' {$hover_tooltip}>" . $image_html . "<p><span>{$item['title']}</span></p>" . "<span class='item-data' {$data_str}></span>" . '</div>'); } else { $thumbs[] = array('tab' => $item['tab'], 'html' => "<div class='inner {$inner_classes}' {$hover_tooltip}>" . $image_html . "<p><span>{$item['title']}</span></p>" . "<span class='item-data' {$data_str}></span>" . '</div>'); } } return $thumbs; }
<div class="fw-option-box-options fw-force-xs"> <?php echo fw()->backend->render_options($box_options, $values, array('id_prefix' => $data['id_prefix'] . $id . '-' . $i . '-', 'name_prefix' => $data['name_prefix'] . '[' . $id . '][' . $i . ']')); ?> </div> <?php echo fw()->backend->render_box($data['id_prefix'] . $id . '-' . $i . '-box', ' ', ob_get_clean(), array('html_after_title' => $controls_html, 'attr' => array('class' => 'fw-option-type-addable-box-pending-title-update'))); ?> </div> <?php } unset($values); ?> </div> <br class="default-box-template fw-hidden" data-template="<?php /** * Place template in attribute to prevent it to be treated as html * when this option will be used inside another option template */ $values = array(); // must contain characters that will remain the same after htmlspecialchars() $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_placeholder . ']') . '">' . fw()->backend->render_box($data['id_prefix'] . $id . '-' . $increment_placeholder . '-box', ' ', '<div class="fw-option-box-options fw-force-xs">' . fw()->backend->render_options($box_options, $values, array('id_prefix' => $data['id_prefix'] . $id . '-' . $increment_placeholder . '-', 'name_prefix' => $data['name_prefix'] . '[' . $id . '][' . $increment_placeholder . ']')) . '</div>', array('html_after_title' => $controls_html)) . '</div>'); ?> "> <div class="fw-option-boxes-controls"> <?php echo fw_html_tag('button', array('type' => 'button', 'onclick' => 'return false;', 'class' => 'button fw-option-boxes-add-button', 'data-increment' => ++$i, 'data-increment-placeholder' => $increment_placeholder, 'data-limit' => intval($option['limit'])), __('Add', 'fw')); ?> </div> </div>
?> <?php echo sprintf(__('The %s extension is disabled', 'fw'), $ext_title); ?> : <a href="#" onclick="jQuery(this).closest('form').submit(); return false;"><?php echo sprintf(__('Activate %s', 'fw'), $ext_title); ?> </a> </form> <?php $requirements[] = ob_get_clean(); } else { if ($can_install && isset($lists['available'][$req_ext])) { $ext_title = $lists['available'][$req_ext]['name']; $requirements[] = sprintf(__('The %s extension is not installed: %s', 'fw'), $ext_title, fw_html_tag('a', array('href' => $link . '&sub-page=install&extension=' . $req_ext), sprintf(__('Install %s', 'fw'), $ext_title))); } else { $requirements[] = sprintf(__('The %s extension is not installed', 'fw'), $ext_title); } } } } break; default: trigger_error('Invalid requirement: ' . $req_name, E_USER_WARNING); continue; } } ?> <a onclick="return false;" href="#" class="fw-extension-tip" title="<?php echo fw_htmlspecialchars('<div class="fw-extension-tip-content">' . '<ul class="fw-extension-requirements"><li>- ' . implode('</li><li>- ', $requirements) . '</li></ul>' . '</div>');
} } fw_render_view($extension_view_path, array('name' => $name, 'title' => $data['name'], 'description' => $data['description'], 'link' => $link, 'lists' => &$lists, 'nonces' => $nonces, 'default_thumbnail' => $default_thumbnail, 'can_install' => $can_install), false); $something_displayed = true; } unset($data); } ?> </div> <?php if ($something_displayed) { ?> <!-- show/hide not compatible extensions --> <p class="fw-text-center toggle-not-compat-ext-btn-wrapper"><?php echo fw_html_tag('a', array('href' => '#', 'onclick' => 'return false;', 'class' => 'button toggle-not-compat-ext-btn', 'style' => 'box-shadow:none;'), '<span class="the-show-text">' . __('Show other extensions', 'fw') . '</span>' . '<span class="the-hide-text fw-hidden">' . __('Hide other extensions', 'fw') . '</span>'); ?> </p> <script type="text/javascript"> jQuery(function($){ if ( !$('.fw-extensions-list .fw-extensions-list-item.not-compatible').length || <?php echo empty($lists['supported']) ? 'true' : 'false'; ?> ) { // disable the show/hide feature $('#fw-extensions-list-wrapper .toggle-not-compat-ext-btn-wrapper').addClass('fw-hidden'); } else { $('#fw-extensions-list-wrapper .fw-extensions-list .fw-extensions-list-item.not-compatible').fadeOut('fast');
<?php if (!defined('FW')) { die('Forbidden'); } $choices = fw()->extensions->get('slider')->get_populated_sliders_choices(); if (!empty($choices)) { $options = array('slider_id' => array('type' => 'select', 'label' => __('Select Slider', 'fw'), 'choices' => fw()->extensions->get('slider')->get_populated_sliders_choices()), 'width' => array('type' => 'text', 'label' => __('Set width', 'fw'), 'value' => 300), 'height' => array('type' => 'text', 'label' => __('Set height', 'fw'), 'value' => 200)); } else { $options = array('slider_id' => array('type' => 'hidden'), 'no-forms' => array('type' => 'html-full', 'label' => false, 'desc' => false, 'html' => '<div>' . '<h1 style="font-weight:100; text-align:center; margin-top:80px">' . __('No Sliders Available', 'fw') . '</h1>' . '<p style="text-align:center">' . '<em>' . str_replace(array('{br}', '{add_slider_link}'), array('<br/>', fw_html_tag('a', array('href' => admin_url('post-new.php?post_type=' . fw()->extensions->get('slider')->get_post_type()), 'target' => '_blank'), __('create a new Slider', 'fw'))), __('No Sliders created yet. Please go to the {br}Sliders page and {add_slider_link}.', 'fw')) . '</em>' . '</p>' . '</div>')); }
<div class="fw-backend-option-fixed-width"> <select class="js-option-type-icon-dropdown"> <?php echo fw_html_tag('option', array('value' => 'all'), htmlspecialchars(__('All Categories', 'fw'))); foreach ($groups as $group_id => $group_title) { $selected = isset($set['icons'][$data['value']]['group']) && $set['icons'][$data['value']]['group'] === $group_id; echo fw_html_tag('option', array('value' => $group_id, 'selected' => $selected), htmlspecialchars($group_title)); } ?> </select> </div> <?php } ?> <div class="option-type-icon-list js-option-type-icon-list <?php echo esc_attr($set['container-class']); ?> "> <?php foreach ($icons as $icon_id => $icon_tab) { $active = $data['value'] == $icon_id ? 'active' : ''; echo fw_html_tag('i', array('class' => "{$icon_id} js-option-type-icon-item {$active}", 'data-value' => $icon_id, 'data-group' => $icon_tab['group']), true); } ?> </div> </div> </div>
<div class="content"></div> <a href="#" class="dashicons fw-x delete-item"></a> </div> <?php foreach ($data['value'] as $key => $value) { ?> <div class="item"> <div class="input-wrapper"> <?php echo fw()->backend->option_type('hidden')->render('', array('value' => json_encode($value)), array('id_prefix' => $data['id_prefix'] . $id . '-' . $key . '-', 'name_prefix' => $data['name_prefix'] . '[' . $id . ']')); ?> </div> <img src="<?php echo $sortable_image; ?> " class="sort-item"/> <div class="content"><!-- will be populated from js --></div> <a href="#" class="dashicons fw-x delete-item"></a> </div> <?php } ?> </div> <!--<div class="dashicons dashicons-plus add-new-item"></div>--> <?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>
public function _filter_admin_footer_text($html) { if ((current_user_can('update_themes') || current_user_can('update_plugins')) && fw_current_screen_match(array('only' => array(array('parent_base' => fw()->extensions->manager->get_page_slug()))))) { return (empty($html) ? '' : $html . '<br/>') . '<em>' . str_replace(array('{wp_review_link}', '{facebook_share_link}', '{twitter_share_link}'), array(fw_html_tag('a', array('target' => '_blank', 'href' => 'https://wordpress.org/support/view/plugin-reviews/unyson?filter=5#postform'), __('leave a review', 'fw')), fw_html_tag('a', array('target' => '_blank', 'href' => 'https://www.facebook.com/sharer/sharer.php?' . http_build_query(array('u' => 'http://unyson.io')), 'onclick' => 'return !window.open(this.href, \'Facebook\', \'width=640,height=300\')'), __('Facebook', 'fw')), fw_html_tag('a', array('target' => '_blank', 'href' => 'https://twitter.com/home?' . http_build_query(array('status' => __('Unyson WordPress Framework is the fastest and easiest way to develop a premium theme. I highly recommend it', 'fw') . ' http://unyson.io/ #UnysonWP')), 'onclick' => 'return !window.open(this.href, \'Twitter\', \'width=640,height=430\')'), __('Twitter', 'fw'))), __('If you like Unyson, {wp_review_link}, share on {facebook_share_link} or {twitter_share_link}.', 'fw')) . '</em>'; } else { return $html; } }
data.$elements.find('.fw-settings-form-header:not(.initialized)').addClass('initialized'); }); }); </script> <?php } ?> <?php echo fw()->backend->render_options($options, $values); ?> <div class="form-footer-buttons"> <!-- This div is required to follow after options in order to have special styles in case options will contain tabs (css adjacent selector + ) --> <?php echo implode($side_tabs ? ' ' : ' ', apply_filters('fw_settings_form_footer_buttons', array(fw_html_tag('input', array('type' => 'submit', 'name' => '_fw_save_options', 'value' => $texts['save_button'], 'class' => 'button-primary button-large')), fw_html_tag('input', array('type' => 'submit', 'name' => '_fw_reset_options', 'value' => $texts['reset_button'], 'class' => 'button-secondary button-large'))))); ?> </div> <!-- reset warning --> <script type="text/javascript"> jQuery(function($){ $(document.body).on('click.fw-reset-warning', 'form[data-fw-form-id="fw_settings"] input[name="<?php echo esc_js($reset_input_name); ?> "]', function(e){ /** * on confirm() the submit input looses focus * fwForm.isAdminPage() must be able to select the input to send it in _POST * so use alternative solution http://stackoverflow.com/a/5721762 */
protected function _render($id, $option, $data) { return fw_html_tag('input', array('type' => 'hidden', 'name' => $option['attr']['name'], 'id' => $option['attr']['id'], 'value' => $data['value'])); }
echo fw()->backend->render_options($options, $values); ?> <div class="form-footer-buttons"> <!-- This div is required to follow after options in order to have special styles in case options will contain tabs (css adjacent selector + ) --> <?php echo fw_html_tag('input', array('type' => 'submit', 'name' => '_fw_save_options', 'value' => __('Save Changes', 'fw'), 'class' => 'button-primary button-large')); echo $side_tabs ? '' : ' '; echo fw_html_tag('input', array('type' => 'submit', 'name' => '_fw_reset_options', 'value' => __('Reset Options', 'fw'), 'class' => 'button-secondary button-large')); ?> </div> <!-- focus tab --> <?php $focus_tab_id = trim(FW_Request::POST($focus_tab_input_name, FW_Request::GET($focus_tab_input_name, ''))); echo fw_html_tag('input', array('type' => 'hidden', 'name' => $focus_tab_input_name, 'value' => $focus_tab_id)); ?> <script type="text/javascript"> jQuery(function($){ fwEvents.one("fw:options:init", function(){ var $form = $('form[data-fw-form-id="fw_settings"]:first'); $form.on("click", ".fw-options-tabs-wrapper > .fw-options-tabs-list > ul > li > a", function(){ $form.find("input[name='<?php echo esc_js($focus_tab_input_name); ?> ']").val( $(this).attr("href").replace(/^#/, "") // tab id ); });
echo esc_attr($attachment_thumb_url); ?> " alt="<?php echo esc_attr($attachment_filename); ?> "/> <a href="#" class="dashicons fw-x clear-uploads-thumb"></a> </div> <?php } ?> <p><a href="#"><?php echo $is_empty ? $l10n['button_add'] : $l10n['button_edit']; ?> </a></p> <br class="thumb-template-empty fw-hidden" data-template="<?php echo fw_htmlspecialchars('<img src="' . fw_get_framework_directory_uri('/static/img/no-image.png') . '" class="no-image-img" alt="' . esc_attr__('No image', 'fw') . '"/>'); ?> "> <br class="thumb-template-not-empty fw-hidden" data-template="<?php echo fw_htmlspecialchars('<img src="<%- data.src %>" alt="<%- data.alt %>"/>' . '<a href="#" class="dashicons fw-x clear-uploads-thumb"></a>'); ?> "> <!-- fixes https://github.com/ThemeFuse/Unyson/issues/1309 --> <?php echo fw_html_tag('input', array('type' => 'hidden', 'name' => '_fake[url]', 'value' => intval($input_attr['value']) ? wp_get_attachment_url($input_attr['value']) : '', 'class' => 'fw-option-type-upload-image-url')); ?> </div>
/** * @param string $extension_name * @return array|WP_Error Extensions to merge with db active extensions list */ private function get_extensions_for_activation($extension_name) { $installed_extensions = $this->get_installed_extensions(); $wp_error_id = 'fw_ext_activation'; if (!isset($installed_extensions[$extension_name])) { return new WP_Error($wp_error_id, sprintf(__('Cannot activate the %s extension because it is not installed. %s', 'fw'), $this->get_extension_title($extension_name), fw_html_tag('a', array('href' => $this->get_link() . '&sub-page=install&extension=' . $extension_name), __('Install', 'fw')))); } $extension_parents = array($extension_name); $current_parent = $extension_name; while ($current_parent = $installed_extensions[$current_parent]['parent']) { $extension_parents[] = $current_parent; } $extension_parents = array_reverse($extension_parents); $extensions = array(); foreach ($extension_parents as $parent_extension_name) { $extensions[$parent_extension_name] = array(); } // search sub-extensions foreach ($this->collect_sub_extensions($extension_name, $installed_extensions) as $sub_extension_name => $sub_extension_data) { $extensions[$sub_extension_name] = array(); } $pending_required_search = $extensions; while ($pending_required_search) { foreach (array_keys($pending_required_search) as $pend_req_extension_name) { unset($pending_required_search[$pend_req_extension_name]); unset($required_extensions); // reset reference $required_extensions = array(); $this->collect_required_extensions($pend_req_extension_name, $installed_extensions, $required_extensions); foreach ($required_extensions as $required_extension_name => $required_extension_data) { if (!isset($installed_extensions[$required_extension_name])) { return new WP_Error($wp_error_id, sprintf(__('Cannot activate the %s extension because it is not installed. %s', 'fw'), $this->get_extension_title($required_extension_name), fw_html_tag('a', array('href' => $this->get_link() . '&sub-page=install&extension=' . $required_extension_name), __('Install', 'fw')))); } $extensions[$required_extension_name] = array(); // search sub-extensions foreach ($this->collect_sub_extensions($required_extension_name, $installed_extensions) as $sub_extension_name => $sub_extension_data) { if (isset($extensions[$sub_extension_name])) { continue; } $extensions[$sub_extension_name] = array(); $pending_required_search[$sub_extension_name] = array(); } } } } return $extensions; }
/** * @param string $icon A string that is meant to be an icon (an image, a font icon class, or something else) * @param array Additional attributes * @return string */ function fw_string_to_icon_html($icon, array $attributes = array()) { if (preg_match('/\\.(png|jpg|jpeg|gif|svg|webp)$/', $icon) || preg_match('/^data:image\\//', $icon)) { // http://.../image.png $tag = 'img'; $attr = array('src' => $icon, 'alt' => 'icon'); } elseif (preg_match('/^[a-zA-Z0-9\\-_ ]+$/', $icon)) { // 'font-icon font-icon-class' $tag = 'span'; $attr = array('class' => trim($icon)); } else { // can't detect. maybe it's raw html '<span ...' return $icon; } foreach ($attributes as $attr_name => $attr_val) { if (isset($attr[$attr_name])) { if ($attr_name === 'class') { $attr[$attr_name] .= ' ' . $attr_val; } else { // ignore. do not overwrite already set attributes } } else { $attr[$attr_name] = (string) $attr_val; } } return fw_html_tag($tag, $attr); }
<?php if (!defined('FW')) { die('Forbidden'); } $icon_html = ''; if (fw()->extensions->get('megamenu')->show_icon() && ($icon = fw_ext_mega_menu_get_meta($item, 'icon'))) { $icon_html = '<i class="' . $icon . '"></i> '; } // Make a menu WordPress way echo $args->before; echo fw_html_tag('a', $attributes, $args->link_before . $icon_html . $title . $args->link_after); echo $args->after;
public function _action_admin_notices() { /** * In v2.4.12 was done a terrible mistake https://github.com/ThemeFuse/Unyson-Extensions-Approval/issues/160 * Show a warning with link to install theme supported extensions */ if (!isset($_GET['supported']) && $this->can_install() && (($installed_extensions = $this->get_installed_extensions()) || true) && !isset($installed_extensions['page-builder']) && $this->get_supported_extensions_for_install()) { echo '<div class="error"> <p>', fw_html_tag('a', array('href' => $this->get_link() . '&sub-page=install&supported'), __('Install theme compatible extensions', 'fw')), '</p></div>'; } }
$time = $backup_info->get_failed_at(); } elseif ($backup_info->is_started()) { $status = __('Running', 'fw'); $time = time(); } elseif ($backup_info->is_queued()) { $status = __('Queued', 'fw'); $time = $backup_info->get_queued_at(); } if ($href = $backup->action()->url_backup_download($post_id)) { $action_list[] = fw_html_tag('a', compact('href'), __('Download', 'fw')); } if ($href = $backup->action()->url_backup_cancel($post_id)) { $action_list[] = fw_html_tag('a', compact('href'), __('Cancel', 'fw')); } if ($backup_info->is_finished()) { $action_list[] = fw_html_tag('a', array('href' => $backup->action()->url_backup_trash($post_id)), __('Delete', 'fw')); } ?> <div style="float: left;"> <p><input type="radio" name="backup-radio" value="<?php echo esc_attr($backup->action()->url_backup_restore($post_id)); ?> " /></p> </div> <div style="margin-left: 2em;"> <p> <?php echo $backup->format()->format_date_time_gmt($time); if ($status) { echo ': ', esc_html($status); }
/** * @internal */ public function get_backup_settings_options() { /** * @var FW_Backup_Interface_Cron $cron * @var FW_Backup_Interface_Storage $storage */ if (empty($this->service)) { throw new FW_Backup_Exception(__('No Services: Did init_services was called?', 'fw')); } $schedule_default = 'disabled'; $schedule_choices = array('disabled' => __('Disabled', 'fw')); foreach (wp_get_schedules() as $id => $schedule) { if (strpos($id, 'backup.') === 0) { $schedule_choices[$id] = $schedule['display']; } } $storage_default = null; $storage_choices = array(); $storage_multi_picker_sets = array(); foreach ($this->service_list('FW_Backup_Interface_Storage') as $service_id => $storage) { $storage_choices[$this->encode_storage_id($service_id)] = $storage->get_title(); // default storage layer is Local if ($storage instanceof FW_Backup_Storage_Local) { $storage_default = $this->encode_storage_id($service_id); } if ($storage instanceof FW_Backup_Interface_Multi_Picker_Set) { /** * @var FW_Backup_Interface_Multi_Picker_Set $storage */ $storage_multi_picker_sets[$this->encode_storage_id($service_id)] = $storage->get_multi_picker_set(); } } $options = array(); foreach ($this->cron as $cron) { list($cron_id, $cron_title) = $cron; if ($this->debug) { $desc = __('Age limit of backups in minutes', 'fw'); } else { $desc = __('Age limit of backups in days', 'fw'); } $attr = array('type' => 'text', 'name' => 'fw_options[' . $this->get_option_name($cron_id, 'lifetime') . ']', 'value' => $this->get_option($cron_id, 'lifetime'), 'id' => 'fw-option-' . $this->get_option_name($cron_id, 'lifetime'), 'placeholder' => __('No Limit', 'fw'), 'class' => 'fw-option fw-option-type-text', 'style' => 'width: 90%'); $html = fw_html_tag('input', $attr, ' <b>' . ($this->debug ? __('Minutes', 'fw') : __('Days', 'fw')) . '</b>'); $options[] = array('type' => 'tab', 'title' => $cron_title, 'attr' => array('data-container' => 'backup-settings'), 'options' => array($this->get_option_name($cron_id, 'completed_at') => array('type' => 'hidden', 'value' => 0), $this->get_option_name($cron_id, 'schedule') => array('type' => 'select', 'attr' => array('data-type' => 'backup-schedule'), 'label' => __('Backup Interval', 'fw'), 'desc' => __('Select how often do you want to backup your website.', 'fw'), 'value' => $schedule_default, 'choices' => $schedule_choices), 'group' => array('type' => 'group', 'attr' => array('class' => 'hide-if-disabled'), 'options' => array($this->get_option_name($cron_id, 'storage') => array('type' => 'multi-picker', 'label' => false, 'desc' => false, 'attr' => array('class' => 'hidden'), 'value' => array('selected' => $storage_default), 'picker' => array('selected' => array('type' => 'select', 'label' => __('Backup On', 'fw'), 'desc' => __('Select where do you want your backup to be saved', 'fw'), 'choices' => $storage_choices)), 'sets' => $storage_multi_picker_sets), $this->get_option_name($cron_id, 'lifetime') => array('type' => 'html-fixed', 'label' => __('Backup Age Limit', 'fw'), 'desc' => $desc, 'html' => $html, 'value' => ''))))); } return $options; }
<div class="content"></div> <a href="#" class="dashicons fw-x delete-item"></a> </div> <?php foreach ($data['value'] as $key => $value) { ?> <div class="item"> <div class="input-wrapper"> <?php echo fw()->backend->option_type('hidden')->render('', array('value' => json_encode($value)), array('id_prefix' => $data['id_prefix'] . $id . '-' . $key . '-', 'name_prefix' => $data['name_prefix'] . '[' . $id . ']')); ?> </div> <img src="<?php echo $sortable_image; ?> " class="sort-item"/> <div class="content"><!-- will be populated from js --></div> <a href="#" class="dashicons fw-x delete-item"></a> </div> <?php } ?> </div> <!--<div class="dashicons dashicons-plus add-new-item"></div>--> <?php echo fw_html_tag('button', array('type' => 'button', 'class' => 'button add-new-item', 'onclick' => 'return false;', 'data-increment-placeholder' => $increment_placeholder), fw_htmlspecialchars($option['add-button-text'])); ?> </div>
/** * @internal */ public function _action_post_form_type_save() { if (!fw_ext_mailer_is_configured()) { FW_Flash_Messages::add('fw-ext-forms-' . $this->get_form_type() . '-mailer', str_replace(array('{mailer_link}'), array(version_compare(fw()->manifest->get_version(), '2.1.7', '>=') ? fw_html_tag('a', array('href' => fw()->extensions->manager->get_extension_link('forms')), __('Mailer', 'fw')) : __('Mailer', 'fw')), __('Please configure the {mailer_link} extension.', 'fw')), 'error'); } }
/** * Render form's html */ public function render($data = array()) { echo fw_html_tag('form', $this->attr); if (!empty($this->attr['action']) && $this->attr['method'] == 'get') { /** * Add query vars from action attribute url to hidden inputs to not loose them * For cases when get_search_link() will return '.../?s=~', * the 's' will be lost after submit and no search page will be shown */ parse_str(parse_url($this->attr['action'], PHP_URL_QUERY), $query_vars); if (!empty($query_vars)) { foreach ($query_vars as $var_name => $var_value) { ?> <input type="hidden" name="<?php print esc_attr($var_name); ?> " value="<?php print esc_attr($var_value); ?> " /><?php } } } ?> <input type="hidden" name="<?php print self::$id_input_name; ?> " value="<?php print $this->id; ?> " /><?php if ($this->attr['method'] == 'post') { wp_nonce_field('submit_fwf', '_nonce_' . md5($this->id)); } $render_data = array('submit' => array('value' => __('Submit', 'fw'), 'html' => null), 'data' => $data, 'attr' => $this->attr); unset($data); if ($this->callbacks['render']) { $data = call_user_func_array($this->callbacks['render'], array($render_data)); if (empty($data)) { // fix if returned wrong data from callback $data = $render_data; } $render_data = $data; unset($data); } // In filter can be defined custom html for submit button if (isset($render_data['submit']['html'])) { print $render_data['submit']['html']; } else { ?> <input type="submit" value="<?php print $render_data['submit']['value']; ?> "><?php } ?> </form><?php }