function repair_child_theme()
 {
     $parent_theme_path = get_template_directory();
     $child_theme_path = get_stylesheet_directory();
     if ($parent_theme_path == $child_theme_path) {
         return;
     }
     $functions_file_content = file_get_contents("{$child_theme_path}/functions.php");
     $updated_content = preg_replace('/\\bbuilder_add_scripts\\b/', 'builder_child_theme_add_scripts', $functions_file_content);
     if ($functions_file_content != $updated_content) {
         if (false === $this->update_file("{$child_theme_path}/functions.php", $updated_content)) {
             ITError::admin_warn('unable_to_update_child_theme', __('In order for Builder to function properly, the child theme must have its <code>builder_add_scripts</code> function (and all references to that function, such as in <code>add_action</code> function calls) replaced with a new name such as <code>builder_child_theme_add_scripts</code>. Builder attempted to do this automatically, but it was unable to do so. This is likely due to file permissions. Either fix the file permissions so that Builder can handle this fix automatically or update your child theme\'s <code>functions.php</code> file manually.', 'it-l10n-Builder-Madison'));
         }
         return;
     }
 }
Exemplo n.º 2
0
 function active_init()
 {
     global $builder_settings_tabs;
     $tab_order = array_keys($builder_settings_tabs);
     $this->_editor_tabs = apply_filters('builder_filter_theme_settings_tabs', $builder_settings_tabs);
     $this->_tab_order = apply_filters('builder_filter_theme_settings_tab_order', $tab_order);
     ksort($this->_tab_order);
     $this->_active_tab = !empty($_REQUEST['editor_tab']) ? $_REQUEST['editor_tab'] : reset($this->_tab_order);
     if (!isset($this->_editor_tabs[$this->_active_tab])) {
         ITError::fatal('The active tab for the Theme Settings page does not exist in the theme_settings_tabs array. This indicates that some custom code added a tab using the builder_filter_theme_settings_tab_order filter but did not update the registered tabs using the builder_filter_theme_settings_tabs filter.');
     }
     require_once dirname(__FILE__) . '/class.settings-tab.php';
     foreach ((array) $this->_editor_tabs as $id => $tab) {
         if (is_null($tab['class'])) {
             continue;
         }
         if (!empty($tab['file']) && is_file($tab['file'])) {
             require_once $tab['file'];
         }
         if (!class_exists($tab['class'])) {
             ITError::fatal("The {$this->_editor_tabs[$this->_active_tab]['class']} class should have been registered. However, the class was not found.");
         }
         $object = new $tab['class']($this);
         if ($id == $this->_active_tab) {
             $this->_tab_object = $object;
         }
     }
     $this->_tabless_self_link = $this->_self_link;
     $this->_self_link .= "&editor_tab={$this->_active_tab}";
     if (method_exists($this->_tab_object, 'init')) {
         $this->_tab_object->init();
     }
     if (isset($_POST['save']) && method_exists($this->_tab_object, 'save_handler')) {
         $this->_tab_object->save_handler();
     }
     if (isset($_POST['reset']) && method_exists($this->_tab_object, 'reset_handler')) {
         $this->_tab_object->reset_handler();
     }
 }
 public static function handle_error($error)
 {
     if (!($error['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR))) {
         return;
     }
     $message = "<h2>Error Message</h2>\n";
     $message .= "<pre>Fatal Error: {$error['message']} in {$error['file']} on line {$error['line']}</pre>\n";
     $message .= "<h2>Description</h2>\n";
     if (preg_match('/Out of memory \\(allocated (\\d*)/', $error['message'], $match) || preg_match('/Allowed memory size of (\\d*)/', $error['message'], $match)) {
         $memory_limit = $match[1] / 1024 / 1024;
         $message .= "<p>PHP exceeded the maximum amount of memory that it can use while rendering this page. The error message indicates that a specific file is the cause of the problem, but this file isn't necessarily doing anything incorrectly. All code will consume some memory. It just so happened that the memory limit was reached while running code in the file indicated in the error message.</p>\n";
         $message .= "<p>Your site is configured to allow PHP to use a maximum of <code>{$memory_limit} megabytes</code> of memory. ";
         if ($memory_limit <= 32) {
             $message .= "This amount of memory can be very limiting as it will only allow for a few plugins and a simple theme to run on the site before the memory is used up.";
         } else {
             if ($memory_limit <= 64) {
                 $message .= "This amount of memory should be sufficient for most sites. Some more complex plugins and themes may require a large amount of memory to run properly. However, if you are only running very simple plugins and a very simple theme, this error could indicate that there is a problem with one of them.";
             } else {
                 $message .= "This is a large amount of memory which should only be exceeded in very rare cases. While increasing the memory limit can allow all the current code to run, disabling some of the plugins that are consuming large amounts of memory should be considered.";
             }
         }
         $message .= "</p>\n";
         $message .= "<h2>Solutions</h2>\n";
         $message .= "<ul>\n";
         $message .= "<li>Disabling some plugins should reduce the amount of memory used and will return site functionality. You can manually deactivate a plugin by using FTP to rename an active plugin's directory (such as renaming <code>public_html/wp-content/plugins/sample-plugin</code> to <code>public_html/wp-content/plugins/sample-plugin.bak</code>).</li>\n";
         $message .= "<li>If you need to raise PHP's maximum memory limit, contact your hosting provider for instructions on how to do this.</li>\n";
         $message .= "</ul>\n";
     } else {
         require_once dirname(__FILE__) . '/class-it-classes-fatal-error-parser.php';
         $error_parser = new IT_Classes_Fatal_Error_Parser($error);
         $message .= $error_parser->get_message();
         if (false === $message) {
             return;
         }
     }
     ITError::show_fatal_error_message($message);
 }
Exemplo n.º 4
0
 public static function upgrade_storage($data)
 {
     if (version_compare($data['storage_version'], '1.0.0', '<')) {
         $data = ITError::_upgrade_storage_1_0_0($data);
     }
     return $data;
 }
Exemplo n.º 5
0
 function __validate_config()
 {
     if (!function_exists('get_post_type_object')) {
         return false;
     }
     if (empty($this->_var)) {
         it_classes_load('it-error.php');
         ITError::admin_warn('it-post-type-missing-var', "Unable to load {$this->_class} due to missing _var.", 'edit_plugins');
         return false;
     }
     if (empty($this->_file)) {
         it_classes_load('it-error.php');
         ITError::admin_warn('it-post-type-missing-file', "Unable to load {$this->_class} due to missing _file.", 'edit_plugins');
         return false;
     }
     return true;
 }
Exemplo n.º 6
0
 function ITStorage2($var, $args = array())
 {
     if (is_string($args)) {
         $args = array('version' => $args);
     }
     $default_args = array('version' => 0, 'autoload' => true);
     $args = wp_parse_args($args, $default_args);
     $this->_var = $var;
     $this->_option_name = "it-storage-{$var}";
     $this->_storage_version = $args['version'];
     $this->_autoload = !$args['autoload'] || 'no' === $args['autoload'] ? 'no' : 'yes';
     if (empty($this->_var)) {
         ITError::fatal('empty_parameter:0', 'Unable to store or retrieve data due to empty first parameter passed to ITStorage2.');
     }
     add_action('it_storage_reset', array(&$this, 'reset'));
     add_action('it_storage_remove', array(&$this, 'remove'));
     add_action("it_storage_clear_cache_{$this->_var}", array(&$this, 'clear_cache'));
     add_action("it_storage_save_{$this->_var}", array(&$this, 'save'));
     add_action("it_storage_reset_{$this->_var}", array(&$this, 'reset'));
     add_action("it_storage_remove_{$this->_var}", array(&$this, 'remove'));
     add_filter("it_storage_load_{$this->_var}", array(&$this, 'load'));
 }
Exemplo n.º 7
0
 function render_sidebar_block_contents($fields, $side)
 {
     $data = $fields['data'];
     if ('none' === $data['sidebar']) {
         return;
     }
     if (empty($data['sidebar_widths'])) {
         ITError::admin_warn('empty_var:parameter:data[\'sidebar_widths\']', __('Unable to decide widths due to missing sidebar_widths value.', 'it-l10n-Builder-Cohen'));
     }
     $name = $this->_get_sidebar_name($fields['layout'], $fields['guid'], $data);
     if (method_exists($this, '_render_sidebar_block_contents')) {
         $this->_render_sidebar_block_contents($fields, $side, $name);
     }
     if (true === $this->_has_sidebars && !empty($data['sidebar'])) {
         if ("2_{$side}" === $data['sidebar']) {
             echo "<div class='widget-outer-wrapper widget-outer-wrapper-top'>\n";
             $this->_render_sidebar($fields, "{$name} - Top", array('class' => array('widget-wrapper', 'widget-wrapper-single', 'widget-wrapper-top', 'single', 'widget-wrapper-1', 'clearfix')));
             echo "</div>\n";
             echo "<div class='widget-section-wrapper clearfix'>\n";
             echo "<div class='widget-outer-wrapper widget-outer-wrapper-left'>\n";
             $this->_render_sidebar($fields, "{$name} - Left", array('class' => array('widget-wrapper', 'widget-wrapper-left', 'left', 'widget-wrapper-1', 'clearfix')));
             echo "</div>\n";
             echo "<div class='widget-outer-wrapper widget-outer-wrapper-right'>\n";
             $this->_render_sidebar($fields, "{$name} - Right", array('class' => array('widget-wrapper', 'widget-wrapper-right', 'right', 'widget-wrapper-2', 'clearfix')));
             echo "</div>\n";
             echo "</div>\n";
             echo "<div class='widget-outer-wrapper widget-outer-wrapper-bottom'>\n";
             $this->_render_sidebar($fields, "{$name} - Bottom", array('class' => array('widget-wrapper', 'widget-wrapper-single', 'widget-wrapper-bottom', 'single', 'widget-wrapper-1', 'clearfix')));
             echo "</div>\n";
         } else {
             if (preg_match("/^(1_{$side}|split)\$/", $data['sidebar'])) {
                 if ('left' === $side) {
                     $width = $this->_widths['sidebar_widths'][0];
                 } else {
                     $width = '1_right' === $data['sidebar'] ? $this->_widths['sidebar_widths'][0] : $this->_widths['sidebar_widths'][1];
                 }
                 $this->_render_sidebar($fields, "{$name} - " . ucfirst($side), array('class' => array('widget-wrapper', 'widget-wrapper-single', 'single', 'widget-wrapper-1', 'clearfix')));
             }
         }
     }
 }
Exemplo n.º 8
0
 public static function sort_array_by_index($array, $index)
 {
     if (!is_array($array)) {
         ITError::fatal('invalid_var:parameter:array', 'Invalid data was passed to ITUtility::sort_array_by_index. This indicates a code bug.');
     }
     $new_array = array();
     $indexes = array();
     foreach ((array) $array as $sub_index => $sub_array) {
         $indexes[$sub_index] = $sub_array[$index];
     }
     asort($indexes);
     foreach ((array) $indexes as $sub_index => $sub_value) {
         $new_array[] = $array[$sub_index];
     }
     return $new_array;
 }
Exemplo n.º 9
0
 function _load()
 {
     if (false === $this->_storage) {
         return;
     }
     if (!isset($this->_storage) || !is_callable(array($this->_storage, 'load'))) {
         ITError::fatal("empty_var:class_var:{$this->_class}->_storage", "The {$this->_class} class did not set the \$this->_storage variable. This should be set by the ITCoreClass class, ensure that the ITCoreClass::ITCoreClass() method is called.");
     }
     $this->_options = $this->_storage->load();
 }