/**
  * Add a line of data to this graph.
  *
  * @param array  $points
  * @param string $label
  * @param array  $options
  *
  * @throws \UnexpectedValueException
  */
 public function add_data_set($points, $label = '', $options = array())
 {
     if (count($points) !== count($this->labels)) {
         throw new \UnexpectedValueException('usage: count($points) == count($labels)');
     }
     $defaults = array('data' => $points, 'label' => $label);
     $this->data_sets[] = \ITUtility::merge_defaults($options, $defaults);
 }
Esempio n. 2
0
function builder_theme_settings_set_defaults($defaults)
{
    global $builder_theme_feature_options;
    $new_defaults = array('include_pages' => array('home'), 'include_cats' => array(), 'javascript_code_header' => '', 'javascript_code_footer' => '', 'identify_widget_areas' => 'admin', 'identify_widget_areas_method' => 'empty', 'enable_comments_page' => '', 'enable_comments_post' => '1', 'comments_disabled_message' => 'none', 'tag_as_keyword' => 'yes', 'cat_index' => 'no', 'google_analytics_enable' => '', 'woopra_enable' => '', 'gosquared_enable' => '', 'gallery_default_render_method' => 'columns', 'activation_child_theme_setup' => 'ask', 'activation_default_layouts' => 'ask');
    foreach ((array) $builder_theme_feature_options as $features) {
        foreach ((array) $features as $feature => $details) {
            $new_defaults["theme_supports_{$feature}"] = $details['default_enabled'];
        }
    }
    $defaults = ITUtility::merge_defaults($defaults, $new_defaults);
    $defaults = apply_filters('builder_filter_theme_settings_defaults', $defaults);
    // Legacy
    $defaults = apply_filters('builder_filter_default_settings', $defaults);
    return $defaults;
}
Esempio n. 3
0
        function _end_table_edit($form, $results = true)
        {
            ?>
	<tr><td><label for="enable_eval"><?php 
            _e('Enable PHP', 'it-l10n-Builder-Cohen');
            ?>
</label></td>
		<td>
			<?php 
            $form->add_drop_down('enable_eval', array('no' => __('No', 'it-l10n-Builder-Cohen'), 'yes' => __('Yes', 'it-l10n-Builder-Cohen')));
            ?>
 <?php 
            ITUtility::add_tooltip(__('Enabling this option allows for processing of PHP code inside the module. <strong>Always review the PHP code if taken from a third party as it could pose a serious security threat.</strong>', 'it-l10n-Builder-Cohen'));
            ?>
		</td>
	</tr>
<?php 
        }
Esempio n. 4
0
function builder_get_builder_core_default_layouts()
{
    $layouts = array();
    $default_data_path = dirname(__FILE__) . '/default-data';
    if (is_callable('json_decode')) {
        $defaults = json_decode(file_get_contents("{$default_data_path}/default-layouts.json"), true);
    } else {
        if (is_callable('base64_decode')) {
            $defaults = @unserialize(base64_decode(file_get_contents("{$default_data_path}/default-layouts.base64")));
        } else {
            $defaults = unserialize(file_get_contents("{$default_data_path}/default-layouts.txt"));
        }
    }
    include_once dirname(__FILE__) . '/upgrade-storage.php';
    $data = apply_filters('it_storage_upgrade_layout_settings', array('data' => $defaults));
    $defaults = $data['data'];
    require_once dirname(__FILE__) . '/layout-settings-guid-randomizer.php';
    $defaults = BuilderLayoutSettingsGUIDRandomizer::randomize_guids($defaults);
    return ITUtility::merge_defaults($layouts, $defaults);
}
/**
 * Create an update record.
 *
 * @api
 *
 * @since 1.0
 *
 * @param array $args
 *
 * @return \ITELIC\Update|WP_Error
 */
function itelic_create_update($args)
{
    $defaults = array('activation' => '', 'release' => '', 'update_date' => '', 'previous_version' => '');
    $args = ITUtility::merge_defaults($args, $defaults);
    $activation = is_numeric($args['activation']) ? itelic_get_activation($args['activation']) : $args['activation'];
    if (!$activation) {
        return new WP_Error('invalid_activation', __("Invalid activation record.", \ITELIC\Plugin::SLUG));
    }
    $release = is_numeric($args['release']) ? itelic_get_release($args['release']) : $args['release'];
    if (!$release) {
        return new WP_Error('invalid_release', __("Invalid release object.", \ITELIC\Plugin::SLUG));
    }
    if (!empty($args['update_date'])) {
        $update_date = is_string($args['update_date']) ? \ITELIC\make_date_time($args['update_date']) : $args['update_date'];
        if (!$update_date instanceof DateTime) {
            return new WP_Error("invalid_update_date", __("Invalid update date.", \ITELIC\Plugin::SLUG));
        }
    } else {
        $update_date = null;
    }
    return \ITELIC\Update::create($activation, $release, $update_date, $args['previous_version']);
}
Esempio n. 6
0
 function _sorter($a, $b)
 {
     $a = ITUtility::get_array_value($this->_array[$a], $this->_index);
     $b = ITUtility::get_array_value($this->_array[$b], $this->_index);
     if ('numeric' === $this->_args['sort_type']) {
         if ($a == $b) {
             return 0;
         }
         if ('asc' === $this->_args['sort_direction']) {
             return $a > $b ? -1 : 1;
         }
         return $a > $b ? 1 : -1;
     }
     if ('desc' === $this->_args['sort_direction']) {
         if (true === $this->_args['case_sensitive']) {
             return strnatcmp($b, $a);
         }
         return strnatcasecmp($b, $a);
     }
     if (true === $this->_args['case_sensitive']) {
         return strnatcmp($a, $b);
     }
     return strnatcasecmp($a, $b);
 }
Esempio n. 7
0
function builder_add_fitvids_scripts()
{
    $base_url = ITUtility::get_url_from_file(dirname(__FILE__));
    wp_register_script('fitvids', "{$base_url}/js/jquery.fitvids-max-width-modification.js", array('jquery'), '1.0', true);
    wp_enqueue_script('builder-init-fitvids', "{$base_url}/js/init-fitvids.js", array('fitvids'), '1.0', true);
}
Esempio n. 8
0
 function _render($fields)
 {
     $data = $fields['data'];
     if (!empty($data['attachment'])) {
         if (!wp_attachment_is_image($data['attachment'])) {
             return;
         }
         $post = get_post($data['attachment']);
         $file = get_attached_file($data['attachment']);
     } else {
         if (!empty($data['manual_file'])) {
             $file = builder_main_get_builder_core_path() . '/lib/layout-engine/default-images/' . $data['manual_file'];
             if (!file_exists($file)) {
                 return;
             }
         }
     }
     $image_width = $fields['widths']['element_width'];
     it_classes_load('it-file-utility.php');
     if ('custom' == $data['height_type']) {
         $resized_image = ITFileUtility::resize_image($file, $image_width, $data['height'], true);
     } else {
         $resized_image = ITFileUtility::resize_image($file, $image_width);
     }
     if (!is_array($resized_image) && is_wp_error($resized_image)) {
         echo "<!-- Resize Error: " . $resized_image->get_error_message() . " -->";
     } else {
         $image_url = $resized_image['url'];
     }
     if (!empty($data['url'])) {
         $attributes['href'] = $data['url'];
         if (!empty($data['new_window'])) {
             $attributes['target'] = '_blank';
         }
         ITUtility::print_open_tag('a', $attributes);
     }
     if (!empty($data['image_alt'])) {
         $alt = $data['image_alt'];
     }
     if (empty($alt)) {
         $alt = get_post_meta($data['attachment'], '_wp_attachment_image_alt', true);
     }
     if (empty($alt)) {
         $alt = $data['name'];
     }
     $attributes = array('src' => $image_url, 'alt' => $alt);
     $new_attributes = apply_filters('builder_image_module_filter_img_attributes', $attributes, $fields);
     if (empty($new_attributes)) {
         $new_attributes = $attributes;
     } else {
         if (empty($new_attributes['src'])) {
             $new_attributes['src'] = $attributes['src'];
         }
     }
     $attributes = $new_attributes;
     ITUtility::print_self_closing_tag('img', $attributes);
     if (!empty($data['url'])) {
         echo "</a>";
     }
 }
Esempio n. 9
0
 public static function warn($code, $message)
 {
     ITUtility::show_error_message($message);
 }
Esempio n. 10
0
        function _show_import_confirm_screen($import = null)
        {
            if (is_null($import)) {
                require_once dirname(__FILE__) . '/class.builder-import-export.php';
                $import = new BuilderImportExport($_REQUEST['guid']);
            }
            $info = $import->get_info();
            $details = array('name' => __('Name', 'it-l10n-Builder-Cohen'), 'timestamp' => __('Date and Time', 'it-l10n-Builder-Cohen'), 'exported_by' => __('Exported By', 'it-l10n-Builder-Cohen'), 'builder_version' => __('Builder Version', 'it-l10n-Builder-Cohen'), 'site_url' => __('Site Address', 'it-l10n-Builder-Cohen'));
            $form = new ITForm(array(), true);
            ?>
	<div class="wrap">
		<?php 
            ITUtility::screen_icon();
            ?>
		<h2>Confirm Import Options</h2>
		
		<p><?php 
            _e('Selected export file details:', 'it-l10n-Builder-Cohen');
            ?>
</p>
		
		<table style="text-align:left;margin-left:20px;">
			<?php 
            foreach ((array) $details as $var => $description) {
                ?>
				<?php 
                $val = $info[$var];
                if ('timestamp' === $var) {
                    $val = gmdate('Y-m-d H:i:s', $info['timestamp'] + get_option('gmt_offset') * 3600);
                }
                if ('site_url' === $var) {
                    $val = "<a href='" . esc_attr($val) . "'>{$val}</a>";
                }
                ?>
				<tr><th scope="row" style="padding-right:20px;"><?php 
                echo $description;
                ?>
</th>
					<td><?php 
                echo $val;
                ?>
</td>
				</tr>
			<?php 
            }
            ?>
		</table>
		<br />
		
		<p><?php 
            _e('The data will be imported with the following settings:', 'it-l10n-Builder-Cohen');
            ?>
</p>
		
		<?php 
            $form->start_form(array(), "import_run_guid_{$_REQUEST['guid']}");
            ?>
			<?php 
            $import->show_data_source_import_process($form);
            ?>
			
			<p class="submit">
				<?php 
            $form->add_submit('run', __('Run Import', 'it-l10n-Builder-Cohen'));
            ?>
				<?php 
            $form->add_submit('cancel', array('value' => __('Cancel', 'it-l10n-Builder-Cohen'), 'class' => 'button-secondary'));
            ?>
			</p>
			
			<?php 
            $form->add_hidden_no_save('guid', $_REQUEST['guid']);
            ?>
			<?php 
            $form->add_hidden_no_save('action', 'import_run');
            ?>
			<?php 
            $form->add_hidden_no_save('editor_tab', 'import-export');
            ?>
		<?php 
            $form->end_form();
            ?>
	</div>
<?php 
        }
 /**
  * Add a line of data to this graph.
  *
  * @param string $value
  * @param string $label
  * @param array  $options
  *
  * @throws \UnexpectedValueException
  */
 public function add_data_set($value, $label = '', $options = array())
 {
     $defaults = array('value' => $value, 'label' => $label);
     $this->data_sets[] = \ITUtility::merge_defaults($options, $defaults);
 }
Esempio n. 12
0
function builder_create_child_theme($args = array())
{
    $default_args = array('child_directory' => false, 'overwrite_existing' => false, 'name' => false, 'source_directory' => get_template_directory(), 'source_type' => 'parent', 'parent_directory' => get_template_directory());
    extract(ITUtility::merge_defaults($args, $default_args));
    if (empty($name)) {
        $name = sprintf(__('%s - Custom', 'it-l10n-Builder-Paige'), $themes[basename($parent_directory)]->get('Name'));
    }
    $name = preg_replace('/^\\s+/', '', $name);
    $name = preg_replace('/\\s+$/', '', $name);
    $themes = wp_get_themes();
    $names = array();
    foreach ($themes as $theme) {
        $names[] = $theme->get('Name');
    }
    if (in_array($name, $names)) {
        $count = 2;
        while (in_array("{$name} {$count}", $names)) {
            $count++;
        }
        $name = "{$name} {$count}";
    }
    if (empty($child_directory)) {
        $child_directory = preg_replace('/[^a-z0-9]+/i', '-', ucfirst($name));
        if (!preg_match('/^builder/i', $child_directory)) {
            $child_directory = "Builder-{$child_directory}";
        }
        $child_directory = dirname($parent_directory) . "/{$child_directory}";
    }
    if (is_dir($child_directory) && !$overwrite_existing) {
        $count = 2;
        while (is_dir("{$child_directory}-{$count}")) {
            $count++;
        }
        $child_directory .= "-{$count}";
    }
    it_classes_load('it-file-utility.php');
    if ('copy' == $source_type) {
        ITFileUtility::copy($source_directory, $child_directory, array('folder_mode' => 0775, 'file_mode' => 0664));
        $stylesheet = file_get_contents("{$child_directory}/style.css");
        $stylesheet = preg_replace('/(Theme Name:\\s*).*/i', "\$1{$name}", $stylesheet);
        file_put_contents("{$child_directory}/style.css", $stylesheet);
    } else {
        ITFileUtility::mkdir($child_directory, array('create_index' => false));
        $files = array('style.css' => '', 'style-mobile.css' => '', 'style-tablet.css' => '', 'style-responsive.css' => '', 'rtl.css' => '', 'functions-child.php' => 'functions.php', 'screenshot.png' => '', 'screenshot.jpg' => '', 'screenshot.gif' => '', 'images' => '', 'lang' => '', 'plugin-features' => '');
        $files = apply_filters('builder-filter-files-to-copy-to-child', $files);
        $stylesheet_data_headers = array('name' => 'Theme Name', 'theme_uri' => 'Theme URI', 'description' => 'Description', 'author' => 'Author', 'author_uri' => 'Author URI', 'version' => 'Version', 'license' => 'License', 'license_uri' => 'License URI', 'tags' => 'Tags', 'text_domain' => 'Text Domain', 'domain_path' => 'Domain Path', 'template' => 'Template');
        $stylesheet_data = get_file_data("{$parent_directory}/style.css", $stylesheet_data_headers);
        $stylesheet_data['description'] = sprintf(__('This is a generated child theme for the %1$s theme. You should activate and modify this theme instead of %1$s. Doing so allows you to modify this child theme while allowing automatic upgrades for %1$s.', 'it-l10n-Builder-Paige'), $stylesheet_data['name']);
        $stylesheet_data['name'] = $name;
        $stylesheet_data['template'] = basename($parent_directory);
        $child_header = "/*\n";
        foreach ($stylesheet_data_headers as $index => $header) {
            $child_header .= "{$header}: {$stylesheet_data[$index]}\n";
        }
        $child_header .= '*/';
        if (isset($files['style.css'])) {
            $stylesheet = file_get_contents("{$parent_directory}/style.css");
            $stylesheet = preg_replace('|/\\*.*Theme Name:.*?\\*/|si', $child_header, $stylesheet);
        } else {
            $stylesheet = "{$child_header}\n\n\n@import url('../" . basename($parent_directory) . "/style.css');";
        }
        file_put_contents("{$child_directory}/style.css", $stylesheet);
        foreach ($files as $source => $destination) {
            if ('style.css' == $source) {
                continue;
            }
            if (!file_exists("{$parent_directory}/{$source}")) {
                continue;
            }
            if (empty($destination)) {
                $destination = $source;
            }
            ITFileUtility::copy("{$parent_directory}/{$source}", "{$child_directory}/{$destination}", array('folder_mode' => 0775, 'file_mode' => 0664));
        }
    }
    add_option('builder_manually_switched_theme', true);
    switch_theme(basename($child_directory));
}
Esempio n. 13
0
 function add_stylesheet()
 {
     if (empty($this->layout)) {
         return;
     }
     remove_action('wp_head', array($this, 'add_stylesheet'), 0, -100);
     $current_stylesheet_version = $this->get_current_stylesheet_version();
     $this->stylesheet_version = $current_stylesheet_version;
     if (!isset($this->layout['stylesheet_version'])) {
         $this->layout['stylesheet_version'] = '';
     }
     if (builder_theme_supports('builder-disable-stylesheet-cache')) {
         $this->stylesheet_type = 'disabled-cache';
         $this->layout['stylesheet_file'] = '';
     } else {
         if ($current_stylesheet_version != (string) $this->layout['stylesheet_version'] || !empty($_GET['builder_force_regenerate_stylesheet'])) {
             $this->stylesheet_type = 'regenerated';
             $this->generate_stylesheet($this->layout_id, $this->layout_settings);
         } else {
             $this->stylesheet_type = 'cached';
         }
         if (!empty($this->layout['stylesheet_file'])) {
             if (is_string($this->layout['stylesheet_file']) && file_exists($this->layout['stylesheet_file'])) {
                 $url = ITUtility::get_url_from_file($this->layout['stylesheet_file']);
             } else {
                 if (is_wp_error($this->layout['stylesheet_file'])) {
                     echo "\n<!--\n\t" . __('Builder Error: Unable to find a writable location to store the generated stylesheet. Check directory permissions in the wp-content/uploads directory.', 'it-l10n-Builder-Madison') . "\n";
                     echo "\t" . sprintf(__('Error Message (%s): %s', 'it-l10n-Builder-Madison'), $this->layout['stylesheet_file']->get_error_code(), $this->layout['stylesheet_file']->get_error_message()) . "\n";
                     echo "-->\n";
                 }
             }
         }
         if (!empty($url)) {
             $version = md5($current_stylesheet_version);
             echo "<link rel=\"stylesheet\" href=\"{$url}?version={$version}\" type=\"text/css\" media=\"screen\" />\n";
             return;
         }
     }
     if (empty($this->stylesheet)) {
         $this->generate_stylesheet($this->layout_id, $this->layout_settings);
     }
     if (empty($this->stylesheet_type)) {
         $this->stylesheet_type = 'fallback';
     }
     echo "<style type=\"text/css\" media=\"screen\">\n{$this->stylesheet}</style>\n";
 }
Esempio n. 14
0
        function meta_box_comments($form)
        {
            ?>
	<?php 
            if (!empty($this->_comment_post_types)) {
                ?>
		<p><?php 
                printf(__('Most comments settings for your site are provided by WordPress in the <a href="%s">Settings &gt; Discussion</a> page. The following settings customize options specific to the theme.', 'it-l10n-Builder-Cohen'), admin_url('options-discussion.php'));
                ?>
</p>
		<hr />
		
		<p><?php 
                _e('Displaying comments and the comment entry form can be enabled or disabled for each type of content by checking or unchecking the appropriate checkboxes below. When a content type has comments disabled, neither any comment counts, existing comments, the comment entry form, nor the "comments are closed" message will be shown.', 'it-l10n-Builder-Cohen');
                ?>
</p>
		<p><?php 
                _e('Comments can be disabled on a per-entry basis. If comments are not appearing, modify the specific entry (post, page, etc) that should have comments to ensure that the "Allow comments" checkbox under "Discussion" is checked.', 'it-l10n-Builder-Cohen');
                ?>
</p>
		<p><?php 
                _e('Which content types should display comment counts (in listings), comments, the comment form, and "comments are closed" messages?', 'it-l10n-Builder-Cohen');
                ?>
</p>
		<ul class="no-bullets">
			<?php 
                foreach ((array) $this->_comment_post_types as $post_type => $details) {
                    ?>
				<li>
					<label for="enable_comments_<?php 
                    echo $post_type;
                    ?>
"><?php 
                    $form->add_check_box("enable_comments_{$post_type}");
                    ?>
 <?php 
                    echo $details['name'];
                    ?>
</label>
					<?php 
                    ITUtility::add_tooltip($details['description']);
                    ?>
				</li>
			<?php 
                }
                ?>
		</ul>
		<br />
		
		<p><?php 
                _e('What should be displayed if comments have been disabled for a specific entry? This message will be shown in place of the comment entry form.', 'it-l10n-Builder-Cohen');
                ?>
</p>
		<ul class="no-bullets">
			<li><label for="comments_disabled_message_none"><?php 
                $form->add_radio('comments_disabled_message', array('value' => 'none', 'id' => 'comments_disabled_message_none'));
                ?>
 <?php 
                _e('Do not display any message (default)', 'it-l10n-Builder-Cohen');
                ?>
</label></li>
			<li><label for="comments_disabled_message_standard"><?php 
                $form->add_radio('comments_disabled_message', array('value' => 'standard', 'id' => 'comments_disabled_message_standard'));
                ?>
 <?php 
                _e('Display message provided by theme, default in Builder is "Comments are closed."', 'it-l10n-Builder-Cohen');
                ?>
</label></li>
			<li><label for="comments_disabled_message_custom"><?php 
                $form->add_radio('comments_disabled_message', array('value' => 'custom', 'id' => 'comments_disabled_message_custom'));
                ?>
 <?php 
                _e('Custom message: ', 'it-l10n-Builder-Cohen');
                ?>
</label> <?php 
                $form->add_text_box('comments_disabled_message_custom_message', array('style' => 'width:400px;'));
                ?>
</li>
		</ul>
	<?php 
            } else {
                ?>
		<p><?php 
                _e('It appears that comments are disabled on your site due to a plugin or other configuration. All post types are reporting that they do not support commenting.', 'it-l10n-Builder-Cohen');
                ?>
</p>
	<?php 
            }
        }
Esempio n. 15
0
 function _reset_data()
 {
     $this->_storage->reset();
     $this->_options = $this->_storage->load();
     $GLOBALS['wp_theme_options'] = $this->_options;
     ITUtility::show_status_message(__('Data reset', 'it-l10n-Builder-Cohen'));
 }
Esempio n. 16
0
 function _print_meta_tag($meta, $meta_content)
 {
     if (empty($meta_content)) {
         return;
     }
     $attributes = array('name' => $meta, 'content' => $meta_content);
     $this->_head .= "\t" . ITUtility::get_open_tag('meta', $attributes) . "\n";
 }
Esempio n. 17
0
 public static function get_file_from_url($url)
 {
     return ITUtility::get_file_from_url($url);
 }
 function show_import_process($form, $info, $data, $post_data)
 {
     $meta = $data['meta'];
     $data = $data['data'];
     $layout_settings = $this->get_layout_settings();
     $updated_layout_settings = $this->_get_updated_layout_settings($layout_settings, $data, $post_data, $meta);
     $final_layout_settings = $updated_layout_settings['info']['layouts'];
     $final_layout_settings['data'] = $updated_layout_settings['data']['layouts'];
     $final_view_settings = $updated_layout_settings['info']['views'];
     $final_view_settings['data'] = $updated_layout_settings['data']['views'];
     if (!empty($final_layout_settings['actions']['kept'])) {
         echo '<h4>' . __('Keeping Site Layouts', 'it-l10n-Builder-Cohen') . "</h4>\n";
         echo "<div style='margin-left:20px;'>\n";
         echo "<p>" . __('The following Layouts on the site will be kept:', 'it-l10n-Builder-Cohen') . "</p>\n";
         echo "<ul>\n";
         foreach ((array) $final_layout_settings['actions']['kept'] as $guid) {
             echo "<li>{$final_layout_settings['data'][$guid]['description']}</li>\n";
         }
         echo "</ul>\n";
         echo "</div>\n";
     }
     if (!empty($final_layout_settings['actions']['imported'])) {
         echo '<h4>' . __('Importing Layouts', 'it-l10n-Builder-Cohen') . "</h4>\n";
         echo "<div style='margin-left:20px;'>\n";
         echo "<p>" . __('The following Layouts from the export file will be imported:', 'it-l10n-Builder-Cohen') . "</p>\n";
         echo "<ul>\n";
         foreach ((array) $final_layout_settings['actions']['imported'] as $guid) {
             $renamed = '';
             if (isset($final_layout_settings['actions']['renamed'][$guid])) {
                 $renamed = '&nbsp;&nbsp;&nbsp;<i>' . sprintf(__('(renamed from &quot;%s&quot;)', 'it-l10n-Builder-Cohen'), $final_layout_settings['actions']['renamed'][$guid]) . '</i>';
             }
             echo "<li>{$final_layout_settings['data'][$guid]['description']}{$renamed}</li>\n";
         }
         echo "</ul>\n";
         echo "</div>\n";
     }
     if (!empty($final_layout_settings['actions']['removed'])) {
         echo '<h4>' . __('Removing Site Layouts', 'it-l10n-Builder-Cohen') . "</h4>\n";
         echo "<div style='margin-left:20px;'>\n";
         echo "<p>" . __('The following Layouts on the site will be removed:', 'it-l10n-Builder-Cohen') . "</p>\n";
         echo "<ul>\n";
         $layout_settings['layouts'] = ITUtility::sort_array($layout_settings['layouts'], 'description');
         foreach ((array) array_keys($layout_settings['layouts']) as $guid) {
             if (in_array($guid, $final_layout_settings['actions']['removed'])) {
                 echo "<li>{$layout_settings['layouts'][$guid]['description']}</li>\n";
             }
         }
         echo "</ul>\n";
         echo "</div>\n";
     }
     /*			if ( ! empty( $final_layout_settings['actions']['skipped'] ) ) {
     				echo '<h4>'. __( 'Skipping Imported Layouts', 'it-l10n-Builder-Cohen' ) . "</h4>\n";
     				echo "<div style='margin-left:20px;'>\n";
     				echo "<p>" . __( 'The following Layouts from the export file will not be imported:', 'it-l10n-Builder-Cohen' ) . "</p>\n";
     				echo "<ul>\n";
     				
     				foreach ( (array) $final_layout_settings['actions']['skipped'] as $guid )
     					echo "<li>{$data['layouts'][$guid]['description']}</li>\n";
     				
     				echo "</ul>\n";
     				echo "</div>\n";
     			}*/
     if ('add' !== $post_data['method'] && !empty($final_view_settings['data'])) {
         echo '<h4>' . __('Final View Settings', 'it-l10n-Builder-Cohen') . "</h4>\n";
         echo "<div style='margin-left:20px;'>\n";
         echo "<p>" . __('The site will use the following Views:', 'it-l10n-Builder-Cohen') . "</p>\n";
         echo "<ul>\n";
         $temp_layout_settings = $layout_settings;
         $temp_layout_settings['layouts'] = $final_layout_settings['data'];
         $temp_layout_settings['views'] = $final_view_settings['data'];
         foreach ((array) $final_view_settings['data'] as $id => $guid) {
             $description = $this->_get_view_description($id, $temp_layout_settings);
             $description = sprintf(__('<strong>%1$s</strong> uses the &quot;%2$s&quot; layout', 'it-l10n-Builder-Cohen'), $description['description'], $description['layout']);
             echo "<li>{$description}</li>\n";
         }
         echo "</ul>\n";
         echo "</div>\n";
     }
     if ('add' !== $post_data['method']) {
         echo '<h4>' . __('Default Layout', 'it-l10n-Builder-Cohen') . "</h4>\n";
         echo "<div style='margin-left:20px;'>\n";
         echo $final_layout_settings['data'][$updated_layout_settings['data']['default']]['description'];
         echo "</div>\n";
     }
 }
Esempio n. 19
0
 function _render($fields)
 {
     $data = $fields['data'];
     if (is_numeric($data['type'])) {
         if (function_exists('is_nav_menu') && is_nav_menu($data['type'])) {
             $menu = wp_get_nav_menu_object($data['type']);
             wp_nav_menu(array('menu' => $data['type'], 'container_class' => "menu-{$menu->slug}-container {$fields['class_prefix']}-navigation-menu-wrapper"));
         }
     } else {
         echo "<div class='{$fields['class_prefix']}-navigation-menu-wrapper'>\n";
         echo "<ul class='menu'>\n";
         if ('pages' === $data['type']) {
             $include_pages_setting = builder_get_theme_setting('include_pages');
             if (!empty($include_pages_setting)) {
                 if (in_array('home', (array) $include_pages_setting)) {
                     $classes = 'home';
                     if (is_front_page()) {
                         $classes .= ' current_page_item';
                     }
                     $link = get_option('home');
                     $link = ITUtility::fix_url($link);
                     echo "<li class='{$classes}'><a href='{$link}'>" . __('Home', 'it-l10n-Builder-Cohen') . "</a></li>\n";
                 }
                 if (in_array('site_name', (array) $include_pages_setting)) {
                     $classs = 'site-name';
                     if (is_front_page()) {
                         $classes .= ' current_page_item';
                     }
                     $link = get_option('home');
                     $link = ITUtility::fix_url($link);
                     $link_text = get_bloginfo('name');
                     echo "<li class='{$classes}'><a href='{$link}'>{$link_text}</a></li>\n";
                 }
                 $include_page_ids = array();
                 foreach ((array) $include_pages_setting as $include_page_id) {
                     if (is_numeric($include_page_id)) {
                         $include_page_ids[] = $include_page_id;
                     }
                 }
                 $exclude_page_ids = apply_filters('wp_list_pages_excludes', array());
                 $include_page_ids = array_diff((array) $include_page_ids, (array) $exclude_page_ids);
                 if (!empty($include_page_ids)) {
                     $include = implode(',', (array) $include_page_ids);
                     $my_pages = "title_li=&depth=0&include={$include}";
                     wp_list_pages($my_pages);
                 }
             }
         } else {
             if ('categories' === $data['type']) {
                 $include_cats_setting = builder_get_theme_setting('include_cats');
                 if (!empty($include_cats_setting)) {
                     $include = implode(',', (array) $include_cats_setting);
                     $my_cats = "title_li=&depth=0&include={$include}";
                     wp_list_categories($my_cats);
                 }
             } else {
                 wp_list_pages('title_li=');
             }
         }
         echo "</ul>\n</div>\n";
     }
 }
Esempio n. 20
0
        function _start_table_edit($form, $results = true)
        {
            $title_types = array('default' => __('Show Site Title (default)', 'it-l10n-Builder-Madison'), 'custom' => __('Use custom Site Title text', 'it-l10n-Builder-Madison'), 'disabled' => __('Do not show Site Title', 'it-l10n-Builder-Madison'));
            $tagline_types = array('default' => __('Show Tagline (default)', 'it-l10n-Builder-Madison'), 'custom' => __('Use custom Tagline text', 'it-l10n-Builder-Madison'), 'disabled' => __('Do not show Tagline', 'it-l10n-Builder-Madison'));
            $seo_types = array('default' => __('Recommended Settings (default)', 'it-l10n-Builder-Madison'), 'custom' => __('Custom', 'it-l10n-Builder-Madison'));
            $tag_options = array('div' => __('div (default)', 'it-l10n-Builder-Madison'), 'h1' => 'h1', 'h2' => 'h2', 'h3' => 'h3', 'h4' => 'h4', 'h5' => 'h5', 'h6' => 'h6');
            $title_home_tag_options = array('div' => 'div', 'h1' => __('h1 (default)', 'it-l10n-Builder-Madison'), 'h2' => 'h2', 'h3' => 'h3', 'h4' => 'h4', 'h5' => 'h5', 'h6' => 'h6');
            ?>
	<tr><td><label for="title_type"><?php 
            _e('Site Title', 'it-l10n-Builder-Madison');
            ?>
</label></td>
		<td>
			<?php 
            $form->add_drop_down('title_type', $title_types);
            ?>
			<?php 
            ITUtility::add_tooltip(__('By default, this is the Site Title as configured in WordPress\' General Settings.', 'it-l10n-Builder-Madison'));
            ?>
			
			<div id="title_type_custom_options">
				<p><label for="title_custom"><?php 
            _e('Custom Site Title', 'it-l10n-Builder-Madison');
            ?>
</label> <?php 
            $form->add_text_box('title_custom');
            ?>
</p>
				<br />
			</div>
		</td>
	</tr>
	<tr><td><label for="tagline_type"><?php 
            _e('Tagline', 'it-l10n-Builder-Madison');
            ?>
</label></td>
		<td>
			<?php 
            $form->add_drop_down('tagline_type', $tagline_types);
            ?>
			<?php 
            ITUtility::add_tooltip(__('By default, this is the Tagline as configured in WordPress\' General Settings.', 'it-l10n-Builder-Madison'));
            ?>
			
			<div id="tagline_type_custom_options">
				<p><label for="tagline_custom"><?php 
            _e('Custom Tagline', 'it-l10n-Builder-Madison');
            ?>
</label> <?php 
            $form->add_text_box('tagline_custom');
            ?>
</p>
				<br />
			</div>
		</td>
	</tr>
	<tr><td><label for="seo_type"><?php 
            _e('SEO', 'it-l10n-Builder-Madison');
            ?>
</label></td>
		<td>
			<?php 
            $form->add_drop_down('seo_type', $seo_types);
            ?>
			<?php 
            ITUtility::add_tooltip(__('By default, the Header Module uses the recommended settings of an <code>h1</code> tag on the Site Title only on the home page view and a <code>div</code> tag all other times.', 'it-l10n-Builder-Madison'));
            ?>
			
			<table id="seo_type_custom_options">
				<tr><th style="text-align:left;" colspan="2"><p><?php 
            _e('Home Page View', 'it-l10n-Builder-Madison');
            ?>
</p></th></tr>
				<tr><td><label for="seo_title_home"><?php 
            _e('Tag for Site Title', 'it-l10n-Builder-Madison');
            ?>
</label></td>
					<td><?php 
            $form->add_drop_down('seo_title_home', $title_home_tag_options);
            ?>
</td>
				</tr>
				<tr><td><label for="seo_tagline_home"><?php 
            _e('Tag for Tagline', 'it-l10n-Builder-Madison');
            ?>
</label></td>
					<td><?php 
            $form->add_drop_down('seo_tagline_home', $tag_options);
            ?>
</td>
				</tr>
				<tr><th style="text-align:left;" colspan="2"><p><?php 
            _e('Other Views', 'it-l10n-Builder-Madison');
            ?>
</p></th></tr>
				<tr><td><label for="seo_title_other"><?php 
            _e('Tag for Site Title', 'it-l10n-Builder-Madison');
            ?>
</label></td>
					<td><?php 
            $form->add_drop_down('seo_title_other', $tag_options);
            ?>
</td>
				</tr>
				<tr><td><label for="seo_tagline_other"><?php 
            _e('Tag for Tagline', 'it-l10n-Builder-Madison');
            ?>
</label></td>
					<td><?php 
            $form->add_drop_down('seo_tagline_other', $tag_options);
            ?>
</td>
				</tr>
			</table>
			<br />
		</td>
	</tr>
	<tr><td colspan="2">&nbsp;</td></tr>
<?php 
        }
Esempio n. 21
0
function builder_show_setup_tab_notice()
{
    ITUtility::show_status_message(sprintf(__('Go to Builder\'s <a href="%s">Setup page</a> to finish setting up the Builder theme.', 'it-l10n-Builder-Paige'), admin_url('admin.php?page=theme-settings&editor_tab=setup&theme_activation=1')));
}
 function run_import($settings = array(), $use_post_data = true, $return_data = false, $db_data = false)
 {
     $default_settings = array('data_sources' => array('layouts-views' => array('method' => 'add'), 'theme-settings' => array('method' => 'skip')));
     $settings = ITUtility::merge_defaults($settings, $default_settings);
     if ($use_post_data) {
         $post_data = ITForm::get_post_data(true);
         $settings = ITUtility::merge_defaults($post_data, $settings);
     }
     it_classes_load('it-file-utility.php');
     $info = $this->get_info();
     $errors = array();
     $results = array();
     $attachments = $this->get_attachments();
     $new_attachments = array();
     foreach ((array) $attachments as $id => $file) {
         $attachment = ITFileUtility::add_to_media_library($file);
         $new_attachments[$id] = $attachment;
     }
     foreach ((array) $info['data_sources'] as $var => $data_source) {
         if (isset($this->_data_sources[$var])) {
             if (is_callable(array($this->_data_sources[$var], 'run_import'))) {
                 if (!isset($settings['data_sources'][$var])) {
                     $settings['data_sources'][$var] = array();
                 } else {
                     if (isset($settings['data_sources'][$var]['method']) && 'skip' == $settings['data_sources'][$var]['method']) {
                         continue;
                     }
                 }
                 $db_settings = isset($db_data[$var]) ? $db_data[$var] : false;
                 $result = $this->_data_sources[$var]->run_import($info['data_sources'][$var], $this->get_data($var), $settings['data_sources'][$var], $new_attachments, $return_data, $db_settings);
                 if ($return_data) {
                     $results[$var] = $result;
                 }
                 if (false === $result) {
                     $errors[] = "{$var}:failed_run_import";
                 }
             } else {
                 $errors[] = "{$var}:missing_run_import";
             }
         }
     }
     if ($return_data) {
         return $results;
     }
     if (!empty($errors)) {
         return $errors;
     }
     return true;
 }
Esempio n. 23
0
        function _modify_layout()
        {
            $defaults = array('guid' => '', 'description' => '', 'width' => '960', 'hide_widths' => 'no');
            $defaults = apply_filters('builder_filter_layout_editor_default_values', $defaults);
            $layout_widths = array('600' => __('Narrow (600 pixels)', 'it-l10n-Builder-Paige'), '780' => __('Medium (780 pixels)', 'it-l10n-Builder-Paige'), '960' => __('Wide (960 pixels)', 'it-l10n-Builder-Paige'));
            $layout_widths = apply_filters('builder_filter_layout_editor_width_options', $layout_widths);
            foreach ((array) $layout_widths as $width => $description) {
                if ((string) intval($width) != (string) $width) {
                    unset($layout_widths[$width]);
                }
            }
            $layout_widths['custom'] = __('Custom...', 'it-l10n-Builder-Paige');
            if (builder_theme_supports('builder-extensions')) {
                $extensions_data = apply_filters('builder_get_extensions_data', array());
                $extensions = array('' => __('-- No Extension --', 'it-l10n-Builder-Paige'));
                $extension_descriptions = array();
                foreach ((array) $extensions_data as $extension => $extension_data) {
                    $extensions[$extension] = $extension_data['name'];
                    $description = $extension_data['description'];
                    if (!empty($description)) {
                        $description = "<p>{$description}</p>";
                    }
                    if ($extension_data['disable_theme_style']) {
                        $description .= __('<p><strong>Notice:</strong> This Extension replaces theme styling with its own.</p>', 'it-l10n-Builder-Paige');
                    }
                    $extension_descriptions[] = '"' . str_replace('"', '\\"', $extension) . '": "' . str_replace('"', '\\"', $description) . '"';
                }
            }
            /*			$layouts = array();
            			foreach ( (array) $this->_options['layouts'] as $layout_id => $layout_data ) {
            				if ( isset( $_REQUEST['layout'] ) && ( $layout_id == $_REQUEST['layout'] ) )
            					continue;
            				$layouts[$layout_id] = $layout_data['description'];
            			}
            			sort( $layouts );*/
            $layout = array();
            if (isset($this->_cached_layout) && is_array($this->_cached_layout)) {
                $layout = $this->_cached_layout;
            } else {
                if (isset($_REQUEST['layout']) && isset($this->_options['layouts'][$_REQUEST['layout']])) {
                    $layout = $this->_options['layouts'][$_REQUEST['layout']];
                }
            }
            $layout = ITUtility::merge_defaults($layout, $defaults);
            if (isset($layout['width']) && (string) intval($layout['width']) == (string) $layout['width'] && !isset($layout_widths[$layout['width']])) {
                $layout['custom_width'] = $layout['width'];
                $layout['width'] = 'custom';
            }
            if (!empty($layout['extension']) && false !== strpos($layout['extension'], '%WP_CONTENT_DIR%')) {
                $layout['extension'] = basename($layout['extension']);
            }
            $form = new ITForm($layout);
            ?>
	<div class="wrap">
		<?php 
            ITUtility::screen_icon();
            ?>
		
		<?php 
            if (!empty($_REQUEST['layout'])) {
                ?>
			<h2><?php 
                _e('Edit Layout', $this->_var);
                ?>
</h2>
		<?php 
            } else {
                ?>
			<h2><?php 
                _e('Add New Layout', $this->_var);
                ?>
</h2>
		<?php 
            }
            ?>
		
		<?php 
            $form->start_form();
            ?>
			<h3 class="title"><?php 
            _e('Settings', 'it-l10n-Builder-Paige');
            ?>
</h3>
			<table class="form-table">
				<tr><th scope="row"><label for="description"><?php 
            _e('Name', 'it-l10n-Builder-Paige');
            ?>
</label></th>
					<td>
						<?php 
            $form->add_text_box('description', array('size' => '15', 'maxlength' => '15'));
            ?>
						<?php 
            ITUtility::add_tooltip(__('The name helps identify this Layout\'s widget areas. Choose a descriptive, short name.', 'it-l10n-Builder-Paige'));
            ?>
					</td>
				</tr>
				<tr><th scope="row"><label for="width"><?php 
            _e('Width', 'it-l10n-Builder-Paige');
            ?>
</label></th>
					<td>
						<?php 
            $form->add_drop_down('width', $layout_widths);
            ?>
						<?php 
            ITUtility::add_tooltip(__('The width determines how wide the Layout is. Typically, a wider width is better for more complex Layouts that have multiple sidebars while a more narrow width is better for minimalistic Layouts such as one that does not use any sidebars.'));
            ?>
						<div id="layout-width-custom" style="display:none;">
							<label>
								<?php 
            _e('Custom Width', 'it-l10n-Builder-Paige');
            ?>
								<?php 
            $form->add_text_box('custom_width', array('size' => '4', 'maxlength' => '5'));
            ?>
								<?php 
            _e('pixels', 'it-l10n-Builder-Paige');
            ?>
							</label>
						</div>
					</td>
				</tr>
				<?php 
            if (builder_theme_supports('builder-extensions')) {
                ?>
					<tr><th scope="row"><label for="extension"><?php 
                _e('Extension', 'it-l10n-Builder-Paige');
                ?>
</label></th>
						<td>
							<?php 
                $form->add_drop_down('extension', $extensions);
                ?>
							<?php 
                ITUtility::add_tooltip(__('Extensions can provide additional code that changes the content, provides additional features, or modifies the styling of the Layout.<br /><br />You can find Extensions in your theme\'s directory inside a directory named "extensions".', 'it-l10n-Builder-Paige'));
                ?>
							
							<div id="extension-details"></div>
						</td>
					</tr>
				<?php 
            }
            ?>
				<tr><th scope="row"><label for="hide_widgets"><?php 
            _e('Hide Widget Areas', 'it-l10n-Builder-Paige');
            ?>
</label></th>
					<td>
						<?php 
            $form->add_drop_down('hide_widgets', array('no' => __('No', 'it-l10n-Builder-Paige'), 'yes' => __('Yes', 'it-l10n-Builder-Paige')));
            ?>
						<?php 
            ITUtility::add_tooltip(__('Use this option to hide this Layout\'s widget areas from the <strong>Appearance &gt; Widgets</strong> editor. This makes it easier to work with other Layout\'s widget areas.', 'it-l10n-Builder-Paige'));
            ?>
					</td>
				</tr>
				<?php 
            do_action('builder_editor_add_custom_settings', $layout);
            ?>
			</table>
			
			<h3 class="title">Design</h3>
			<table class="form-table layout-modules">
				<tr class="add-module-help"><td colspan="2"><?php 
            _e('In order to start building your layout, please click the Add Module link below.', 'it-l10n-Builder-Paige');
            ?>
</td></tr>
				<?php 
            $position = 1;
            $max_id = 0;
            if (isset($layout['modules'])) {
                foreach ((array) $layout['modules'] as $id => $module) {
                    if (false !== $this->_add_module_fields($module, $id, $position)) {
                        $position++;
                    }
                    if ($id > $max_id) {
                        $max_id = $id;
                    }
                }
            }
            ?>
			</table>
			
			<p class="submit">
				<?php 
            $form->add_submit('save', array('value' => __('Save Layout', 'it-l10n-Builder-Paige'), 'class' => 'button-primary'));
            ?>
				<?php 
            $form->add_submit('save_and_continue', array('value' => __('Save Layout and Continue Editing', 'it-l10n-Builder-Paige'), 'class' => 'button-secondary'));
            ?>
				<?php 
            $form->add_submit('cancel', array('value' => __('Cancel', 'it-l10n-Builder-Paige'), 'class' => 'button-secondary cancel'));
            ?>
			</p>
			
			<input type="hidden" name="next-position" value="<?php 
            echo $position;
            ?>
" />
			<input type="hidden" name="current-position" value="0" />
			<input type="hidden" name="next-id" value="<?php 
            echo $max_id + 1;
            ?>
" />
			<?php 
            $form->add_hidden('self-link', $this->_self_link);
            ?>
			<?php 
            if (isset($_REQUEST['layout'])) {
                $form->add_hidden('layout', $_REQUEST['layout']);
            }
            ?>
			<?php 
            if (isset($_REQUEST['layout'])) {
                $form->add_hidden('layout-guid', $layout['guid']);
            }
            ?>
			<?php 
            if (isset($_REQUEST['add_layout'])) {
                $form->add_hidden('add_layout', $_REQUEST['add_layout']);
            }
            ?>
			<?php 
            $form->add_hidden('base_url', "{$this->_plugin_url}");
            ?>
		<?php 
            $form->end_form();
            ?>
	</div>
<?php 
            foreach ((array) $this->_modules as $var => $module) {
                echo "<table id=\"module-editor-{$var}\" style=\"display:none;\">";
                $this->_add_module_fields(array('module' => $var, 'data' => array()), '%id%', '%position%');
                echo '</table>';
                $form->add_hidden("module-name-{$var}", $module->_name);
                $form->add_hidden("module-editable-{$var}", method_exists($module, 'edit') ? '1' : '0');
                $form->add_hidden("module-max-{$var}", $module->_max);
            }
            $module_image_paths = array();
            if (is_dir("{$this->_plugin_path}/modules") && ($readdir = opendir("{$this->_plugin_path}/modules"))) {
                while (($module = readdir($readdir)) !== false) {
                    if (preg_match('/^\\.{1,2}$/', $module)) {
                        continue;
                    }
                    if (is_dir("{$this->_plugin_path}/modules/{$module}") && is_dir("{$this->_plugin_path}/modules/{$module}/images")) {
                        $module_image_paths[] = "modules/{$module}/images";
                    }
                }
            }
            echo "<div class=\"preload-images\">\n";
            foreach ((array) $module_image_paths as $path) {
                if ($readdir = opendir("{$this->_plugin_path}/{$path}")) {
                    while (($image = readdir($readdir)) !== false) {
                        if (is_file("{$this->_plugin_path}/{$path}/{$image}") && preg_match('/\\.(png|jpg|jpeg|gif)$/i', $image)) {
                            echo "<img src=\"{$this->_plugin_url}/{$path}/{$image}\" alt=\"preload image\" />\n";
                        }
                    }
                }
            }
            echo "</div>\n";
            ?>
	<script type="text/javascript">
		<?php 
            if (isset($extension_descriptions)) {
                ?>
			var builder_extension_details = {<?php 
                echo implode(",\n", $extension_descriptions);
                ?>
};
		<?php 
            }
            ?>
		
		init_layout_editor();
	</script>
<?php 
        }
Esempio n. 24
0
/**
 * Create a license key.
 *
 * @api
 *
 * @param array $args        {
 *
 * @type string $key         The license key to be used. If empty, one will be
 *       generated.
 * @type int    $transaction Transaction ID. If empty, one will be manually
 *       generated
 * @type int    $product     Product ID.
 * @type int    $customer    Customer ID.
 * @type string $status      The key's status. Accepts 'active', 'expired',
 *       'disabled'
 * @type float  $paid        If manually generating a transaction, the amount
 *       paid.
 * @type int    $limit       Activation limit.
 * @type string $expires     Expiration date. Pass null or empty string for
 *       forever.
 * @type string $date        When the transaction occurred. GMT.
 * }
 *
 * @return \ITELIC\Key|WP_Error
 */
function itelic_create_key($args)
{
    $defaults = array('key' => '', 'transaction' => '', 'product' => '', 'customer' => '', 'status' => '', 'paid' => '');
    $args = ITUtility::merge_defaults($args, $defaults);
    $product = itelic_get_product($args['product']);
    if (!$product->has_feature('licensing')) {
        return new WP_Error('invalid_product', __("Product does not have licensing enabled.", \ITELIC\Plugin::SLUG));
    }
    $customer = it_exchange_get_customer($args['customer']);
    if (!$customer) {
        return new WP_Error('invalid_customer', __("Invalid customer", \ITELIC\Plugin::SLUG));
    }
    $transaction = it_exchange_get_transaction($args['transaction']);
    if (!$args['transaction']) {
        if (!function_exists('it_exchange_manual_purchases_addon_transaction_uniqid')) {
            return new WP_Error('no_manual_purchases', __("Manual purchases add-on is not installed.", \ITELIC\Plugin::SLUG));
        }
        // Grab default currency
        $settings = it_exchange_get_option('settings_general');
        $currency = $settings['default-currency'];
        $description = array();
        $product_id = $product->ID;
        $itemized_data = apply_filters('it_exchange_add_itemized_data_to_cart_product', array(), $product_id);
        if (!is_serialized($itemized_data)) {
            $itemized_data = maybe_serialize($itemized_data);
        }
        $key = $product_id . '-' . md5($itemized_data);
        $products[$key]['product_base_price'] = $product->get_feature('base-price');
        $products[$key]['product_subtotal'] = $products[$key]['product_base_price'];
        //need to add count
        $products[$key]['product_name'] = get_the_title($product_id);
        $products[$key]['product_id'] = $product_id;
        $products[$key]['count'] = 1;
        $description[] = $products[$key]['product_name'];
        $description = apply_filters('it_exchange_get_cart_description', join(', ', $description), $description);
        // Package it up and send it to the transaction method add-on
        $total = empty($args['paid']) ? 0 : it_exchange_convert_to_database_number($args['paid']);
        $object = new stdClass();
        $object->total = number_format(it_exchange_convert_from_database_number($total), 2, '.', '');
        $object->currency = $currency;
        $object->description = $description;
        $object->products = $products;
        remove_action('it_exchange_add_transaction_success', 'ITELIC\\on_add_transaction_generate_license_keys');
        $uniquid = it_exchange_manual_purchases_addon_transaction_uniqid();
        $txn_args = array();
        if (isset($args['date'])) {
            $date = \ITELIC\make_date_time($args['date']);
            $txn_args['post_date'] = \ITELIC\convert_gmt_to_local($date)->format('Y-m-d H:i:s');
            $txn_args['post_date_gmt'] = $date->format('Y-m-d H:i:s');
        }
        $tid = it_exchange_add_transaction('manual-purchases', $uniquid, 'Completed', $customer->id, $object, $txn_args);
        add_action('it_exchange_add_transaction_success', 'ITELIC\\on_add_transaction_generate_license_keys');
        $transaction = it_exchange_get_transaction($tid);
    }
    $factory = new \ITELIC\Key\Factory($product, $customer, $transaction);
    $key = \ITELIC\generate_key_for_transaction_product($transaction, $product, $factory, $args['status'], $args['key']);
    if (isset($args['limit'])) {
        if (empty($args['limit']) || $args['limit'] == '-') {
            $limit = '';
        } else {
            $limit = $args['limit'];
        }
        $key->set_max($limit);
    }
    if (isset($args['expires'])) {
        if (is_string($args['expires'])) {
            $expires = \ITELIC\make_date_time($args['expires']);
        } else {
            $expires = $args['expires'];
        }
        if (!$expires instanceof DateTime) {
            $expires = null;
        }
        $key->set_expires($expires);
    }
    return $key;
}
Esempio n. 25
0
    function _show_layouts_and_views_options()
    {
        $options = array('child_theme_type' => 'parent', 'theme_layouts' => 'ignore', 'theme_activation' => !empty($_REQUEST['theme_activation']) ? 1 : '', 'fresh_install' => !empty($_REQUEST['fresh_install']) ? 1 : '', 'step' => 'finish');
        $logo_url = ITUtility::get_url_from_file(dirname(__FILE__) . '/images/builder-logo.png');
        $old_theme = isset($GLOBALS['builder_old_theme']) ? $GLOBALS['builder_old_theme'] : false;
        $current_theme = wp_get_theme();
        if ($old_theme && $old_theme->get_template() != $current_theme->get_template()) {
            $template_switch = true;
        } else {
            $template_switch = false;
        }
        $form = new ITForm($options);
        $this->_form =& $form;
        ?>
	<div class="wrap">
		<?php 
        $form->start_form(array('id' => 'it-builder-setup'));
        ?>
			<?php 
        if (empty($_REQUEST['theme_activation'])) {
            ?>
				<?php 
            ITUtility::screen_icon();
            ?>
				
				<?php 
            $this->_print_editor_tabs();
            ?>
			<?php 
        }
        ?>
			
			<div class="it-brochure-box">
				<img class="it-logo" src="<?php 
        echo $logo_url;
        ?>
" alt="Builder Logo" />
				
				<h1>Builder Setup</h1>
				
				
				<?php 
        if ($template_switch) {
            ?>
					<p><?php 
            _e('You are switching from a different Builder theme. Would you like to continue to use your current Layouts and Views? Or do you want to use the Layouts and Views included with this new theme?', 'it-l10n-Builder-Paige');
            ?>
</p>
					
					<div class="it-shrink-wrap-box">
						<label><?php 
            printf(__('%1$s Keep the site\'s current Layouts and Views', 'it-l10n-Builder-Paige'), $form->add_radio('theme_layouts', array('value' => 'ignore', 'class' => 'show-hide-toggle')));
            ?>
</label>
						<br />
						<label><?php 
            printf(__('%1$s Use the Layouts and Views included with the new theme', 'it-l10n-Builder-Paige'), $form->add_radio('theme_layouts', array('value' => 'use', 'class' => 'show-hide-toggle')));
            ?>
</label>
						<div class="it-options-theme_layouts it-options-theme_layouts-use">
							<p class="description"><?php 
            _e('Important: This option will replace your current Layouts and Views with the Layouts and Views provided by the theme.', 'it-l10n-Builder-Paige');
            ?>
</p>
						</div>
						
	<!--				<div class="it-indent-box it-options-theme_layouts it-options-theme_layouts-use">
							<label><?php 
            printf(__('%1$s Keep current Layouts', 'it-l10n-Builder-Paige'), $form->add_radio('layouts_import_method', 'add'));
            ?>
</label>
							<br />
							<label><?php 
            printf(__('%1$s Remove current Layouts', 'it-l10n-Builder-Paige'), $form->add_radio('layouts_import_method', 'replace'));
            ?>
</label>
						</div>-->
					</div>
				<?php 
        } else {
            ?>
					<p><?php 
            _e('Your theme provides a set of default Layouts and Views. You can update your site to match these provided Layouts and Views.', 'it-l10n-Builder-Paige');
            ?>
</p>
					
					<div class="it-shrink-wrap-box">
						<label><?php 
            printf(__('%1$s Keep the site\'s current Layouts and Views', 'it-l10n-Builder-Paige'), $form->add_radio('theme_layouts', array('value' => 'ignore', 'class' => 'show-hide-toggle')));
            ?>
</label>
						<br />
						<label><?php 
            printf(__('%1$s Use the Layouts and Views included with the theme', 'it-l10n-Builder-Paige'), $form->add_radio('theme_layouts', array('value' => 'use', 'class' => 'show-hide-toggle')));
            ?>
</label>
						<div class="it-options-theme_layouts it-options-theme_layouts-use">
							<p class="description"><?php 
            _e('Important: This option will replace your current Layouts and Views with the Layouts and Views provided by the theme.', 'it-l10n-Builder-Paige');
            ?>
</p>
						</div>
						
	<!--				<div class="it-indent-box it-options-theme_layouts it-options-theme_layouts-use">
							<label><?php 
            printf(__('%1$s Keep current Layouts', 'it-l10n-Builder-Paige'), $form->add_radio('layouts_import_method', 'add'));
            ?>
</label>
							<br />
							<label><?php 
            printf(__('%1$s Remove current Layouts', 'it-l10n-Builder-Paige'), $form->add_radio('layouts_import_method', 'replace'));
            ?>
</label>
						</div>-->
					</div>
				<?php 
        }
        ?>
				
				<div class="it-input-set">
					<div class="it-options-theme_layouts it-options-theme_layouts-ignore">
						<?php 
        $form->add_submit('update_layouts_and_views', array('value' => 'Keep current Layouts and Views'));
        ?>
					</div>
					
					<div class="it-options-theme_layouts it-options-theme_layouts-use">
						<?php 
        $form->add_submit('update_layouts_and_views', array('value' => 'Update Layouts and Views'));
        ?>
					</div>
					
					
					<p><a class="it-skip" href="<?php 
        echo admin_url('admin.php?page=ithemes-builder-theme');
        ?>
"><?php 
        _e('Skip');
        ?>
</a></p>
				</div>
			</div>
			
			
			<?php 
        $form->add_hidden('theme_activation');
        ?>
			<?php 
        $form->add_hidden('fresh_install');
        ?>
			<?php 
        $form->add_hidden('step');
        ?>
			<?php 
        $form->add_hidden_no_save('editor_tab', $this->_parent->_active_tab);
        ?>
		<?php 
        $form->end_form();
        ?>
	</div>
<?php 
    }
Esempio n. 26
0
 function _get_simple_input($var, $options, $override_value)
 {
     if (empty($options['type'])) {
         return "<!-- _get_simple_input called without a type option set. -->\n";
     }
     $scrublist['textarea']['value'] = true;
     $scrublist['file']['value'] = true;
     $scrublist['dropdown']['value'] = true;
     $scrublist['dropdown']['type'] = true;
     $defaults = array();
     if (isset($this->_args['widget_instance']) && @method_exists($this->_args['widget_instance'], 'get_field_name')) {
         $defaults['name'] = $this->_args['widget_instance']->get_field_name($var);
     } else {
         if (empty($this->_args['prefix'])) {
             $defaults['name'] = $var;
         } else {
             $defaults['name'] = "{$this->_args['prefix']}-{$var}";
         }
     }
     $input_group_name = $defaults['name'];
     $var = str_replace('[]', '', $var);
     $clean_var = trim(preg_replace('/[^a-z0-9_]+/i', '-', $var), '-');
     if (!empty($this->_input_group)) {
         if (false === strpos($defaults['name'], '[')) {
             $defaults['name'] = "[{$defaults['name']}]";
         } else {
             $defaults['name'] = preg_replace('/^([^\\[]+)\\[/', '[$1][', $defaults['name']);
         }
         $input_group_name = $defaults['name'];
         $defaults['name'] = "{$this->_input_group}{$defaults['name']}";
         $clean_var = trim(preg_replace('/[^a-z0-9_]+/i', '-', $defaults['name']), '-');
     }
     if (isset($this->_args['widget_instance']) && @method_exists($this->_args['widget_instance'], 'get_field_id')) {
         $defaults['id'] = $this->_args['widget_instance']->get_field_id($var);
     } else {
         $defaults['id'] = $clean_var;
     }
     if (!empty($options['append_val_to_id']) && true === $options['append_val_to_id'] && !empty($options['value'])) {
         unset($options['append_val_to_id']);
         $defaults['id'] .= '-' . trim(preg_replace('/[^a-z0-9_]+/i', '-', $options['value']), '-');
     }
     $options = ITUtility::merge_defaults($options, $defaults);
     if (false === $override_value && isset($this->_options[$var])) {
         if (in_array($options['type'], array('checkbox', 'radio'))) {
             if (is_array($this->_options[$var]) && in_array($options['value'], $this->_options[$var]) || !is_array($this->_options[$var]) && (string) $this->_options[$var] === (string) $options['value']) {
                 $options['checked'] = 'checked';
             }
         } else {
             if ('dropdown' !== $options['type']) {
                 $options['value'] = $this->_options[$var];
             }
         }
     }
     if (!empty($this->_args['prefix']) && preg_match("|^{$this->_args['prefix']}-|", $options['name']) || empty($this->_args['prefix'])) {
         if (!isset($this->_used_inputs[$this->_input_group]) || !in_array($input_group_name, $this->_used_inputs[$this->_input_group])) {
             $this->_used_inputs[$this->_input_group][] = $input_group_name;
         }
     }
     $attributes = '';
     if (false !== $options) {
         foreach ((array) $options as $name => $val) {
             if (!is_array($val) && (!isset($scrublist[$options['type']][$name]) || true !== $scrublist[$options['type']][$name])) {
                 if ('value' == $name) {
                     $val = ITForm::esc_value_attr($val);
                 } else {
                     if (!in_array($options['type'], array('submit', 'button'))) {
                         $val = esc_attr($val);
                     }
                 }
                 $attributes .= "{$name}=\"{$val}\" ";
             }
         }
     }
     $retval = '';
     if ('textarea' === $options['type']) {
         if (!isset($options['value'])) {
             $options['value'] = '';
         }
         $retval = "<textarea {$attributes} >" . ITForm::esc_value_attr($options['value']) . '</textarea>';
     } else {
         if ('dropdown' === $options['type']) {
             $retval = "<select {$attributes}>\n";
             if (isset($options['value']) && is_array($options['value'])) {
                 foreach ((array) $options['value'] as $val => $name) {
                     if (is_array($name)) {
                         $options = $name;
                         if (preg_match('/^__optgroup_\\d+$/', $val)) {
                             $retval .= "<optgroup class='it-classes-optgroup-separator'>\n";
                         } else {
                             $retval .= "<optgroup label='" . esc_attr($val) . "'>\n";
                         }
                         foreach ((array) $options as $val => $name) {
                             $selected = isset($this->_options[$var]) && (string) $this->_options[$var] === (string) $val ? ' selected="selected"' : '';
                             $retval .= "<option value=\"" . ITForm::esc_value_attr($val) . "\"{$selected}>{$name}</option>\n";
                         }
                         $retval .= "</optgroup>\n";
                     } else {
                         $selected = isset($this->_options[$var]) && (string) $this->_options[$var] === (string) $val ? ' selected="selected"' : '';
                         $retval .= "<option value=\"" . ITForm::esc_value_attr($val) . "\"{$selected}>{$name}</option>\n";
                     }
                 }
             }
             $retval .= "</select>\n";
         } else {
             $retval = '<input ' . $attributes . '/>';
         }
     }
     return $retval;
 }
Esempio n. 27
0
 function filter_default_theme_settings($defaults)
 {
     $new_defaults = array('widget_content_the_content_filter' => 'no', 'widget_content_edit_link' => 'yes');
     $defaults = ITUtility::merge_defaults($defaults, $new_defaults);
     return $defaults;
 }
Esempio n. 28
0
 function _setVars()
 {
     $this->_plugin_url = ITUtility::get_url_from_file(dirname(__FILE__));
 }
Esempio n. 29
0
/**
 * Output the settings form for the 'list' key type.
 *
 * @since 1.0
 *
 * @param int    $product
 * @param string $prefix
 * @param array  $values
 */
function render_key_type_list_settings($product, $prefix, $values = array())
{
    $defaults = array('keys' => '');
    $values = \ITUtility::merge_defaults($values, $defaults);
    ?>
	<label for="itelic-key-type-list"><?php 
    _e("License Keys", Plugin::SLUG);
    ?>
</label>
	<textarea id="itelic-key-type-list" name="<?php 
    echo $prefix;
    ?>
[keys]"><?php 
    echo $values['keys'];
    ?>
</textarea>
	<p class="description">
		<?php 
    _e("Enter in license keys, one per line. If empty, a key will be randomly generated.", Plugin::SLUG);
    ?>
	</p>

	<?php 
}
Esempio n. 30
0
        function _start_table_edit($form, $results = true)
        {
            $types = array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5');
            if (empty($_REQUEST['type'])) {
                $_REQUEST['type'] = '1';
            }
            $default_percents = $this->_get_default_percents();
            if (isset($default_percents[$_REQUEST['type']])) {
                $start_widget_percents = $default_percents[$_REQUEST['type']];
            } else {
                $start_widget_percents = '';
            }
            ?>
	<tr><td><label for="type"><?php 
            _e('Columns', 'it-l10n-Builder-Paige');
            ?>
</label></td>
		<td>
			<?php 
            $form->add_drop_down('type', $types);
            ?>
			<?php 
            ITUtility::add_tooltip(__('Each column becomes a widget area that you can add widgets to.', 'it-l10n-Builder-Paige'));
            ?>
		</td>
	</tr>
	<tr style="vertical-align:top;"><td><?php 
            _e('Column Widths', 'it-l10n-Builder-Paige');
            ?>
</td>
		<td id="widget_percents_row">
			<?php 
            $form->add_drop_down('widget_percents', $start_widget_percents);
            ?>
			<?php 
            ITUtility::add_tooltip(__('You can make the columns wider or narrower by using these options. To get more control over the widths used, select "Custom..." to put in your own widths.', 'it-l10n-Builder-Paige'));
            ?>
			
			<div id="widget-percents-custom" style="display:none;">
				<?php 
            $form->add_text_box('custom_widget_percents', array('size' => '20', 'maxlength' => '30'));
            ?>
<br />
				<?php 
            _e('Specify the percentage width of each widget area.', 'it-l10n-Builder-Paige');
            ?>
<br />
				<?php 
            _e('For example, if you have three widget areas and want to separate them into 20%, 30%, and 50% widths, input <strong><code>20,30,50</code></strong> in the box above.', 'it-l10n-Builder-Paige');
            ?>
			</div>
		</td>
	</tr>
<?php 
        }