-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
5,219 additions
and
5,185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
<?php | ||
/** | ||
* Provides useful helpers for the other classes of the plugin. | ||
* | ||
* @package Helpful\Core | ||
* @author Pixelbart <[email protected]> | ||
* @version 4.3.0 | ||
* @package Helpful | ||
* @subpackage Core | ||
* @version 4.4.50 | ||
* @since 4.3.0 | ||
*/ | ||
namespace Helpful\Core; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
<?php | ||
/** | ||
* Helpful helpers loaded before helpful classes. | ||
* | ||
* @package Helpful | ||
* @author Pixelbart <[email protected]> | ||
* @since 4.4.50 | ||
* @since 4.3.0 | ||
*/ | ||
use Helpful\Core\Helper; | ||
use Helpful\Core\Helpers as Helpers; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
<?php | ||
/** | ||
* Helpful Frontend Helpers for retrieving | ||
* values from database | ||
* | ||
* @package helpful | ||
* @author Pixelbart <[email protected]> | ||
* @package Helpful | ||
* @version 4.4.50 | ||
* @since 4.0.0 | ||
*/ | ||
use Helpful\Core\Helpers as Helpers; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,78 @@ | ||
<?php | ||
/** | ||
* ... | ||
* | ||
* @package Helpful\Core\Helpers | ||
* @author Pixelbart <[email protected]> | ||
* @version 4.3.0 | ||
* @package Helpful | ||
* @subpackage Core\Helpers | ||
* @version 4.4.50 | ||
* @since 4.3.0 | ||
*/ | ||
namespace Helpful\Core\Helpers; | ||
|
||
use Helpful\Core\Helper; | ||
|
||
/* Prevent direct access */ | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
if (!defined('ABSPATH')) { | ||
exit; | ||
} | ||
|
||
class Cache | ||
{ | ||
/** | ||
* Returns the available times for caching with the Transients API from WordPress. | ||
* | ||
* @param boolean $labels Outputs either the miliseconds or the labels for the options. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_cache_times( $labels = true ) | ||
{ | ||
$times = []; | ||
/** | ||
* Returns the available times for caching with the Transients API from WordPress. | ||
* | ||
* @param boolean $labels Outputs either the miliseconds or the labels for the options. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_cache_times($labels = true) | ||
{ | ||
$times = []; | ||
|
||
$times['minute'] = esc_html_x( 'One minute', 'caching time', 'helpful' ); | ||
$times['hour'] = esc_html_x( 'One hour', 'caching time', 'helpful' ); | ||
$times['day'] = esc_html_x( 'One day', 'caching time', 'helpful' ); | ||
$times['week'] = esc_html_x( 'One week', 'caching time', 'helpful' ); | ||
$times['month'] = esc_html_x( 'One month', 'caching time', 'helpful' ); | ||
$times['year'] = esc_html_x( 'One year', 'caching time', 'helpful' ); | ||
$times['minute'] = esc_html_x('One minute', 'caching time', 'helpful'); | ||
$times['hour'] = esc_html_x('One hour', 'caching time', 'helpful'); | ||
$times['day'] = esc_html_x('One day', 'caching time', 'helpful'); | ||
$times['week'] = esc_html_x('One week', 'caching time', 'helpful'); | ||
$times['month'] = esc_html_x('One month', 'caching time', 'helpful'); | ||
$times['year'] = esc_html_x('One year', 'caching time', 'helpful'); | ||
|
||
if ( false === $labels ) { | ||
$times['minute'] = MINUTE_IN_SECONDS; | ||
$times['hour'] = HOUR_IN_SECONDS; | ||
$times['day'] = DAY_IN_SECONDS; | ||
$times['week'] = WEEK_IN_SECONDS; | ||
$times['month'] = MONTH_IN_SECONDS; | ||
$times['year'] = YEAR_IN_SECONDS; | ||
} | ||
if (false === $labels) { | ||
$times['minute'] = MINUTE_IN_SECONDS; | ||
$times['hour'] = HOUR_IN_SECONDS; | ||
$times['day'] = DAY_IN_SECONDS; | ||
$times['week'] = WEEK_IN_SECONDS; | ||
$times['month'] = MONTH_IN_SECONDS; | ||
$times['year'] = YEAR_IN_SECONDS; | ||
} | ||
|
||
return $times; | ||
} | ||
return $times; | ||
} | ||
|
||
/** | ||
* Deletes all transients related to Helpful and clears the cache of Helpful. | ||
* | ||
* @return integer Amount of deleted entries. | ||
*/ | ||
public static function clear_cache() | ||
{ | ||
global $wpdb; | ||
/** | ||
* Deletes all transients related to Helpful and clears the cache of Helpful. | ||
* | ||
* @return integer Amount of deleted entries. | ||
*/ | ||
public static function clear_cache() | ||
{ | ||
global $wpdb; | ||
|
||
$table_name = $wpdb->prefix . 'options'; | ||
$table_name = $wpdb->prefix . 'options'; | ||
|
||
$count = 0; | ||
$sql = "SELECT * FROM $table_name WHERE option_name LIKE '_transient_timeout_helpful_%' OR option_name LIKE '_transient_helpful_%'"; | ||
$rows = $wpdb->get_results( $sql ); | ||
$count = 0; | ||
$sql = "SELECT * FROM $table_name WHERE option_name LIKE '_transient_timeout_helpful_%' OR option_name LIKE '_transient_helpful_%'"; | ||
$rows = $wpdb->get_results($sql); | ||
|
||
if ( $rows ) { | ||
foreach ( $rows as $row ) : | ||
if ( '_transient_timeout_helpful_updated' === $row->option_name || '_transient_helpful_updated' === $row->option_name ) { | ||
continue; | ||
} | ||
if ($rows) { | ||
foreach ($rows as $row): | ||
if ('_transient_timeout_helpful_updated' === $row->option_name || '_transient_helpful_updated' === $row->option_name) { | ||
continue; | ||
} | ||
|
||
$values = [ 'option_name' => $row->option_name ]; | ||
$wpdb->delete( $table_name, $values ); | ||
$count++; | ||
endforeach; | ||
} | ||
$values = ['option_name' => $row->option_name]; | ||
$wpdb->delete($table_name, $values); | ||
$count++; | ||
endforeach; | ||
} | ||
|
||
return $count; | ||
} | ||
} | ||
return $count; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
<?php | ||
/** | ||
* @package Helpful\Core\Helpers | ||
* @author Pixelbart <[email protected]> | ||
* @version 4.4.49 | ||
* @package Helpful | ||
* @subpackage Core\Helpers | ||
* @version 4.4.50 | ||
* @since 4.3.0 | ||
*/ | ||
namespace Helpful\Core\Helpers; | ||
|
||
|
Oops, something went wrong.