Skip to content
This repository was archived by the owner on Sep 18, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions layout/layout-picker-custom-control.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,23 @@ public function render_content()
$finalImageDirectory = get_stylesheet_directory_uri().$imageDirectoryInc;
}
?>
<label>
<span class="customize-layout-control"><?php echo esc_html( $this->label ); ?></span>
<ul>
<li><img src="<?php echo $finalImageDirectory; ?>1col.png" alt="Full Width" /><input type="radio" name="<?php echo $this->id; ?>" id="<?php echo $this->id; ?>[full_width]" value="1" /></li>
<li><img src="<?php echo $finalImageDirectory; ?>2cl.png" alt="Left Sidebar" /><input type="radio" name="<?php echo $this->id; ?>" id="<?php echo $this->id; ?>[left_sidebar]" value="1" /></li>
<li><img src="<?php echo $finalImageDirectory; ?>2cr.png" alt="Right Sidebar" /><input type="radio" name="<?php echo $this->id; ?>" id="<?php echo $this->id; ?>[right_sidebar]" value="1" /></li>
</ul>
</label>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<label>
<img src="<?php echo $finalImageDirectory; ?>1col.png" alt="Full Width" />
<input type="radio" value="full_width" name="<?php echo esc_attr( $this->id ); ?>" <?php $this->link(); checked( $this->value(), "full_width"); ?> />
<br/>
</label>
<label>
<img src="<?php echo $finalImageDirectory; ?>2cl.png" alt="Left Sidebar" />
<input type="radio" value="left_sidebar" name="<?php echo esc_attr( $this->id ); ?>" <?php $this->link(); checked( $this->value(), "left_sidebar"); ?> />
<br/>
</label>
<label>
<img src="<?php echo $finalImageDirectory; ?>2cr.png" alt="Right Sidebar" />
<input type="radio" value="right_sidebar" name="<?php echo esc_attr( $this->id ); ?>" <?php $this->link(); checked( $this->value(), "right_sidebar"); ?> />
<br/>
</label>
<?php
}
}
?>
?>
60 changes: 38 additions & 22 deletions select/google-font-dropdown-custom-control.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,21 @@ public function render_content()
{
?>
<label>
<span class="customize-category-select-control"><?php echo esc_html( $this->label ); ?></span>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<select <?php $this->link(); ?>>
<?php
foreach ( $this->fonts as $k => $v )
{
printf('<option value="%s" %s>%s</option>', $k, selected($this->value(), $k, false), $v->family);
printf('<option value="%s" %s>%s</option>', $v->family, selected($this->value(), $v->family, false), $v->family);
}
?>
</select>
</label>
<?php
} else {
?>
<p>The font list is empty.</p>
<?php
}
}

Expand All @@ -48,10 +52,17 @@ public function render_content()
*
* @return String
*/
public function get_fonts( $amount = 30 )
public function get_fonts( $amount = 600 )
{
$selectDirectory = get_stylesheet_directory().'/wordpress-theme-customizer-custom-controls/select/';
$selectDirectoryInc = get_stylesheet_directory().'/inc/wordpress-theme-customizer-custom-controls/select/';
global $wp_filesystem;
// Initialize the WP filesystem, no more using 'file-put-contents' function
if (empty($wp_filesystem)) {
require_once (ABSPATH . '/wp-admin/includes/file.php');
WP_Filesystem();
}

$selectDirectory = get_stylesheet_directory().'/tbnframework/admin/options/customizer-custon-controls/select/';
$selectDirectoryInc = get_template_directory().'/tbnframework/admin/options/customizer-custon-controls/select/';

$finalselectDirectory = '';

Expand All @@ -66,32 +77,37 @@ public function get_fonts( $amount = 30 )
}

$fontFile = $finalselectDirectory . '/cache/google-web-fonts.txt';

//Total time the file will be cached in seconds, set to a week
$cachetime = 86400 * 7;

if(file_exists($fontFile) && $cachetime < filemtime($fontFile))

//Total time the file will be cached in seconds, set to 180 days
$cachetime = 86400 * 180;
if(file_exists($fontFile) && time() - $cachetime < filemtime($fontFile))
{
$content = json_decode(file_get_contents($fontFile));
$content = json_decode($wp_filesystem->get_contents($fontFile));
} else {

$googleApi = 'https://www.googleapis.com/webfonts/v1/webfonts?sort=popularity&key={API_KEY}';
$Api = '';
$googleApi = 'https://www.googleapis.com/webfonts/v1/webfonts?sort=popularity&key='.$Api;

$fontContent = wp_remote_get( $googleApi, array('sslverify' => false) );

$fp = fopen($fontFile, 'w');
fwrite($fp, $fontContent['body']);
fclose($fp);
if( $wp_filesystem ) {
$wp_filesystem->put_contents(
$fontFile,
$fontContent['body'],
FS_CHMOD_FILE // predefined mode settings for WP files
);
}

$content = json_decode($fontContent['body']);
}

if($amount == 'all')
{
return $content->items;
if( !empty($content->items) ) {
if($amount == 'all') {
return $content->items;
} else {
return array_slice($content->items, 0, $amount);
}
} else {
return array_slice($content->items, 0, $amount);
return false;
}
}
}
?>
?>
8 changes: 4 additions & 4 deletions select/taxonomy-dropdown-custom-control.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public function __construct($manager, $id, $args = array(), $options = array())
*/
public function render_content()
{
// call wp_dropdown_cats to get data and add to select field
add_action( 'wp_dropdown_cats', array( $this, 'wp_dropdown_cats' ) );
// call wp_dropdown_categories to get data and add to select field
add_action( 'wp_dropdown_categories', array( $this, 'wp_dropdown_categories' ) );

// Set defaults
$this->defaults = array(
Expand Down Expand Up @@ -59,11 +59,11 @@ public function render_content()
* @since 11/14/2012
* @return String $output
*/
public function wp_dropdown_cats( $output )
public function wp_dropdown_categories( $output )
{
$output = str_replace( '<select', '<select ' . $this->get_link(), $output );

return $output;
}
}
?>
?>