public function get_title()
 {
     if (is_null($this->title)) {
         return fw_id_to_title($this->id);
     } else {
         return $this->title;
     }
 }
 public final function __construct($data)
 {
     if (!self::$access_key) {
         self::$access_key = new FW_Access_Key('extension');
     }
     $this->rel_path = $data['rel_path'];
     $this->path = $data['path'];
     $this->uri = $data['uri'];
     $this->parent = $data['parent'];
     $this->depth = $data['depth'];
     $this->customizations_locations = $data['customizations_locations'];
     $variables = fw_get_variables_from_file($this->path . '/manifest.php', array('manifest' => array()));
     $manifest = $variables['manifest'];
     unset($variables);
     if (empty($manifest['name'])) {
         $manifest['name'] = fw_id_to_title($this->get_name());
     }
     $this->manifest = new FW_Extension_Manifest($manifest);
 }
 public final function __construct(&$parent, $declared_dir, $declared_source, $URI, $depth)
 {
     if (!self::$access_key) {
         self::$access_key = new FW_Access_Key('extension');
     }
     $this->parent =& $parent;
     $this->declared_source = $declared_source;
     $this->declared_dir = $declared_dir;
     $this->declared_URI = $URI . $this->get_rel_path();
     // ! set $this->parent before calling get_rel_path()
     $this->depth = $depth;
     $manifest = array();
     if (file_exists($this->declared_dir . '/manifest.php')) {
         $variables = fw_get_variables_from_file($this->declared_dir . '/manifest.php', array('manifest' => array()));
         $manifest = $variables['manifest'];
         unset($variables);
     }
     if (empty($manifest['name'])) {
         $manifest['name'] = fw_id_to_title($this->get_name());
     }
     $this->manifest = new FW_Extension_Manifest($manifest);
 }
Beispiel #4
0
 /**
  * @param WP_Customize_Manager $wp_customize
  * @param array $options
  * @param array $parent_data {'type':'...','id':'...'}
  */
 private function customizer_register_options($wp_customize, $options, $parent_data = array())
 {
     $collected = array();
     fw_collect_options($collected, $options, array('limit_option_types' => false, 'limit_container_types' => false, 'limit_level' => 1, 'info_wrapper' => true));
     if (empty($collected)) {
         return;
     }
     foreach ($collected as &$opt) {
         switch ($opt['group']) {
             case 'container':
                 $_collected = array();
                 fw_collect_options($_collected, $opt['option']['options'], array('limit_option_types' => array(), 'limit_container_types' => false, 'limit_level' => 1, 'limit' => 1, 'info_wrapper' => false));
                 $has_containers = !empty($_collected);
                 unset($_collected);
                 $children_data = array('group' => 'container', 'id' => $opt['id']);
                 $args = array('title' => empty($opt['option']['title']) ? fw_id_to_title($opt['id']) : $opt['option']['title'], 'description' => empty($opt['option']['desc']) ? '' : $opt['option']['desc']);
                 if (isset($opt['option']['wp-customizer-args']) && is_array($opt['option']['wp-customizer-args'])) {
                     $args = array_merge($opt['option']['wp-customizer-args'], $args);
                 }
                 if ($has_containers) {
                     if ($parent_data) {
                         trigger_error($opt['id'] . ' panel can\'t have a parent (' . $parent_data['id'] . ')', E_USER_WARNING);
                         break;
                     }
                     $wp_customize->add_panel($opt['id'], $args);
                     $children_data['customizer_type'] = 'panel';
                 } else {
                     if ($parent_data) {
                         if ($parent_data['customizer_type'] === 'panel') {
                             $args['panel'] = $parent_data['id'];
                         } else {
                             trigger_error($opt['id'] . ' section can have only panel parent (' . $parent_data['id'] . ')', E_USER_WARNING);
                             break;
                         }
                     }
                     $wp_customize->add_section($opt['id'], $args);
                     $children_data['customizer_type'] = 'section';
                 }
                 $this->customizer_register_options($wp_customize, $opt['option']['options'], $children_data);
                 unset($children_data);
                 break;
             case 'option':
                 $setting_id = FW_Option_Type::get_default_name_prefix() . '[' . $opt['id'] . ']';
                 $args = array('label' => empty($opt['option']['label']) ? fw_id_to_title($opt['id']) : $opt['option']['label'], 'description' => empty($opt['option']['desc']) ? '' : $opt['option']['desc'], 'settings' => $setting_id);
                 if (isset($opt['option']['wp-customizer-args']) && is_array($opt['option']['wp-customizer-args'])) {
                     $args = array_merge($opt['option']['wp-customizer-args'], $args);
                 }
                 if ($parent_data) {
                     if ($parent_data['customizer_type'] === 'section') {
                         $args['section'] = $parent_data['id'];
                     } else {
                         trigger_error('Invalid control parent: ' . $parent_data['customizer_type'], E_USER_WARNING);
                         break;
                     }
                 } else {
                     // the option is not placed in a section, create a section automatically
                     $args['section'] = 'fw_option_auto_section_' . $opt['id'];
                     $wp_customize->add_section($args['section'], array('title' => empty($opt['option']['label']) ? fw_id_to_title($opt['id']) : $opt['option']['label']));
                 }
                 if (!class_exists('_FW_Customizer_Setting_Option')) {
                     require_once fw_get_framework_directory('/includes/customizer/class--fw-customizer-setting-option.php');
                 }
                 if (!class_exists('_FW_Customizer_Control_Option_Wrapper')) {
                     require_once fw_get_framework_directory('/includes/customizer/class--fw-customizer-control-option-wrapper.php');
                 }
                 $wp_customize->add_setting(new _FW_Customizer_Setting_Option($wp_customize, $setting_id, array('default' => fw()->backend->option_type($opt['option']['type'])->get_value_from_input($opt['option'], null), 'fw_option' => $opt['option'])));
                 $wp_customize->add_control(new _FW_Customizer_Control_Option_Wrapper($wp_customize, $opt['id'], $args));
                 break;
             default:
                 trigger_error('Unknown group: ' . $opt['group'], E_USER_WARNING);
         }
     }
 }
<?php

if (!defined('FW')) {
    die('Forbidden');
}
if (!isset($option['label'])) {
    $option['label'] = fw_id_to_title($id);
}
if (!isset($option['desc'])) {
    $option['desc'] = '';
}
$help = false;
if (!empty($option['help'])) {
    $help = array('icon' => 'info', 'html' => '{undefined}');
    if (is_array($option['help'])) {
        $help = array_merge($help, $option['help']);
    } else {
        $help['html'] = $option['help'];
    }
    switch ($help['icon']) {
        case 'info':
            $help['class'] = 'dashicons dashicons-info';
            break;
        case 'video':
            $help['class'] = 'dashicons dashicons-video-alt3';
            break;
        default:
            $help['class'] = 'dashicons dashicons-smiley';
    }
}
$classes = array('option' => array('form-field', 'fw-backend-option', 'fw-backend-option-design-taxonomy', 'fw-backend-option-type-' . $option['type']), 'label' => array('fw-backend-option-label'), 'input' => array('fw-backend-option-input', 'fw-backend-option-input-type-' . $option['type']), 'desc' => array('description', 'fw-backend-option-desc'));
 public function get_extension_title($extension_name)
 {
     $installed_extensions = $this->get_installed_extensions();
     if (isset($installed_extensions[$extension_name])) {
         return fw_akg('name', $installed_extensions[$extension_name]['manifest'], fw_id_to_title($extension_name));
     }
     unset($installed_extensions);
     $available_extensions = $this->get_available_extensions();
     if (isset($available_extensions[$extension_name])) {
         return $available_extensions[$extension_name]['name'];
     }
     return fw_id_to_title($extension_name);
 }
Beispiel #7
0
                                if (!empty($req_ext_data['min_version'])) {
                                    if (!version_compare($req_ext_data['min_version'], $ext->manifest->get_version(), '<=')) {
                                        if ($can_install) {
                                            $requirements[] = sprintf(__('You need to update the %s extension to %s: %s', 'fw'), $ext->manifest->get_name(), $req_ext_data['min_version'], fw_html_tag('a', array('href' => self_admin_url('update-core.php')), sprintf(__('Update %s', 'fw'), $ext->manifest->get_name())));
                                        } else {
                                            $requirements[] = sprintf(__('The %s extension needs to be updated to %s', 'fw'), $ext->manifest->get_name(), $req_ext_data['min_version']);
                                        }
                                    }
                                }
                                if (!empty($req_ext_data['max_version'])) {
                                    if (!version_compare($req_ext_data['max_version'], $ext->manifest->get_version(), '>=')) {
                                        $requirements[] = sprintf(__('Maximum supported %s extension version is %s', 'fw'), $ext->manifest->get_name(), $req_ext_data['max_version']);
                                    }
                                }
                            } else {
                                $ext_title = fw_id_to_title($req_ext);
                                if (isset($lists['installed'][$req_ext])) {
                                    $ext_title = fw_akg('name', $lists['installed'][$req_ext]['manifest'], $ext_title);
                                    ob_start();
                                    ?>
													<form action="<?php 
                                    echo esc_attr($link);
                                    ?>
&sub-page=activate&extension=<?php 
                                    echo esc_attr($req_ext);
                                    ?>
" method="post" style="display: inline;">
														<?php 
                                    wp_nonce_field($nonces['activate']['action'], $nonces['activate']['name']);
                                    ?>
														<?php 
 /**
  * @param WP_Customize_Manager $wp_customize
  * @param array $options
  * @param array $parent_data {'type':'...','id':'...'}
  */
 private function customizer_register_options($wp_customize, $options, $parent_data = array())
 {
     $collected = array();
     fw_collect_first_level_options($collected, $options);
     if (empty($collected['all'])) {
         return;
     }
     foreach ($collected['all'] as &$opt) {
         switch ($opt['type']) {
             case 'tab':
                 $args = array('title' => $opt['option']['title'], 'description' => empty($opt['option']['desc']) ? '' : $opt['option']['desc']);
                 if ($parent_data) {
                     trigger_error('Not supported panel parent, type: ' . $parent_data['type'], E_USER_WARNING);
                     break;
                 }
                 $wp_customize->add_panel($opt['id'], $args);
                 $this->customizer_register_options($wp_customize, $opt['option']['options'], array('type' => 'panel', 'id' => $opt['id']));
                 break;
             case 'box':
                 $args = array('title' => $opt['option']['title']);
                 if ($parent_data) {
                     if ($parent_data['type'] === 'panel') {
                         $args['panel'] = $parent_data['id'];
                     } else {
                         trigger_error('Not supported section parent, type: ' . $parent_data['type'], E_USER_WARNING);
                         break;
                     }
                 }
                 $wp_customize->add_section($opt['id'], $args);
                 $this->customizer_register_options($wp_customize, $opt['option']['options'], array('type' => 'section', 'id' => $opt['id']));
                 break;
             case 'option':
                 $setting_id = FW_Option_Type::get_default_name_prefix() . '[' . $opt['id'] . ']';
                 $args = array('label' => empty($opt['option']['label']) ? '' : $opt['option']['label'], 'description' => empty($opt['option']['desc']) ? '' : $opt['option']['desc'], 'settings' => $setting_id, 'type' => 'radio', 'choices' => array('a' => 'Demo A', 'b' => 'Demo B'));
                 if ($parent_data) {
                     if ($parent_data['type'] === 'section') {
                         $args['section'] = $parent_data['id'];
                     } else {
                         trigger_error('Not supported control parent, type: ' . $parent_data['type'], E_USER_WARNING);
                         break;
                     }
                 } else {
                     // the option is not placed in a section, create a section automatically
                     $args['section'] = 'fw_option_auto_section_' . $opt['id'];
                     $wp_customize->add_section($args['section'], array('title' => empty($opt['option']['label']) ? fw_id_to_title($opt['id']) : $opt['option']['label']));
                 }
                 if (!class_exists('_FW_Customizer_Control_Option_Wrapper')) {
                     require_once fw_get_framework_directory('/includes/customizer/class--fw-customizer-control-option-wrapper.php');
                 }
                 $wp_customize->add_setting($setting_id, array('default' => fw()->backend->option_type($opt['option']['type'])->get_value_from_input($opt['option'], null)));
                 $control = new _FW_Customizer_Control_Option_Wrapper($wp_customize, $opt['id'], $args, array('fw_option' => $opt['option']));
                 add_filter("customize_sanitize_{$setting_id}", array($control, 'setting_sanitize_callback'), 10, 2);
                 $wp_customize->add_control($control);
                 break;
             default:
                 trigger_error('Not supported option in customizer, type: ' . $opt['type'], E_USER_WARNING);
                 // todo: uncomment
         }
     }
 }
Beispiel #9
0
        } else {
            //trigger_error(sprintf(__('Supported extension "%s" is not available.', 'fw'), $name));
            continue;
        }
    }
    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);
    $displayed[$name] = $something_displayed = true;
}
unset($theme_extensions);
foreach ($lists['disabled'] as $name => &$data) {
    if (isset($displayed[$name])) {
        continue;
    } elseif (true !== fw_akg('display', $data['manifest'], $display_default_value)) {
        continue;
    }
    fw_render_view($extension_view_path, array('name' => $name, 'title' => fw_akg('name', $data['manifest'], fw_id_to_title($name)), 'description' => fw_akg('description', $data['manifest'], ''), 'link' => $link, 'lists' => &$lists, 'nonces' => $nonces, 'default_thumbnail' => $default_thumbnail, 'can_install' => $can_install), false);
    $displayed[$name] = $something_displayed = true;
}
if ($can_install) {
    foreach ($lists['available'] as $name => &$data) {
        if (isset($displayed[$name])) {
            continue;
        } elseif (isset($lists['installed'][$name])) {
            continue;
        } elseif ($data['display'] !== true) {
            continue;
        }
        /**
         * fixme: remove this in the future when this extensions will look good on any theme
         */
        if (in_array($name, array('styling', 'megamenu'))) {
 /**
  * @return FW_Ext_Backups_Demo[]
  */
 private function get_demos()
 {
     if (is_null(self::$demos)) {
         $demos = array();
         foreach (apply_filters('fw_ext_backups_demo_dirs', array(fw_fix_path(get_template_directory()) . '/demo-content' => get_template_directory_uri() . '/demo-content')) as $dir_path => $dir_uri) {
             if (!is_dir($dir_path) || !($dirs = glob($dir_path . '/*', GLOB_ONLYDIR))) {
                 continue;
             }
             foreach (array_map('fw_fix_path', $dirs) as $demo_dir) {
                 $demo_dir_name = basename($demo_dir);
                 if (!file_exists($demo_dir . '/manifest.php')) {
                     continue;
                 }
                 $manifest = fw_get_variables_from_file($demo_dir . '/manifest.php', array('manifest' => array()), array('uri' => $dir_uri . '/' . $demo_dir_name));
                 $manifest = array_merge(array('title' => fw_id_to_title($demo_dir_name), 'screenshot' => fw_get_framework_directory_uri('/static/img/no-image.png'), 'preview_link' => '', 'extra' => array()), $manifest['manifest']);
                 $demo = new FW_Ext_Backups_Demo('local-' . md5($demo_dir), 'local', array('source' => $demo_dir));
                 $demo->set_title($manifest['title']);
                 $demo->set_screenshot($manifest['screenshot']);
                 $demo->set_preview_link($manifest['preview_link']);
                 $demo->set_extra($manifest['extra']);
                 $demos[$demo->get_id()] = $demo;
                 unset($demo);
             }
         }
         self::$demos = array_merge(apply_filters('fw:ext:backups-demo:demos', array()), $demos);
     }
     return self::$demos;
 }
 /**
  * @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.', 'fw'), fw_id_to_title($extension_name)));
     }
     $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.', 'fw'), fw_id_to_title($required_extension_name)));
                 }
                 $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;
 }
 /**
  * Fixes and prepare defaults
  *
  * @param string $id
  * @param array  $option
  * @param array  $data
  * @return array
  */
 private function prepare($id, &$option, &$data)
 {
     $data = array_merge(array('id_prefix' => fw()->backend->get_options_id_attr_prefix(), 'name_prefix' => fw()->backend->get_options_name_attr_prefix()), $data);
     $option = array_merge($this->get_defaults(), $option, array('type' => $this->get_type()));
     if (!isset($option['attr'])) {
         $option['attr'] = array();
     }
     if (!isset($option['title'])) {
         $option['title'] = fw_id_to_title($id);
     }
     $option['attr']['class'] = 'fw-container fw-container-type-' . $option['type'] . (isset($option['attr']['class']) ? ' ' . $option['attr']['class'] : '');
 }
Beispiel #13
0
 * @var array $list_page_link
 */
$count = count($extension_names);
?>

<p><?php 
echo _n('You are about to remove the following extension:', 'You are about to remove the following extensions:', $count, 'fw');
?>
</p>

<ul class="ul-disc">
	<?php 
foreach ($extension_names as $extension_name) {
    ?>
		<li><strong><?php 
    echo fw_akg('name', $installed_extensions[$extension_name]['manifest'], fw_id_to_title($extension_name));
    ?>
</strong></li>
	<?php 
}
?>
</ul>

<p><?php 
echo _n('Are you sure you wish to delete this extension?', 'Are you sure you wish to delete these extensions?', $count, 'fw');
?>
</p>

<input type="submit" name="submit" id="submit" class="button" value="<?php 
echo esc_attr(_n('Yes, Delete this extension', 'Yes, Delete these extensions', $count, 'fw'));
?>