Skip to content

Commit

Permalink
release: fixes
Browse files Browse the repository at this point in the history
- Fixed broken link in the Map settings of the Geo Chart
- Fixed the default cron job sync time for data synchronization [PRO]
  • Loading branch information
vytisbulkevicius authored Jul 9, 2024
2 parents be8fbd8 + 812ed5c commit aec1ac4
Show file tree
Hide file tree
Showing 9 changed files with 568 additions and 73 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/deploy-wporg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ jobs:
SVN_USERNAME: ${{ secrets.SVN_THEMEISLE_USERNAME }}
- name: Send update to the store
env:
THEMEISLE_ID: ${{ secrets.THEMEISLE_ID }}
THEMEISLE_AUTH: ${{ secrets.THEMEISLE_STORE_AUTH }}
PRODUCT_ID: ${{ secrets.THEMEISLE_ID }}
AUTH_TOKEN: ${{ secrets.THEMEISLE_STORE_AUTH }}
STORE_URL: ${{ secrets.THEMEISLE_STORE_URL }}
BUILD_VERSION: ${{ steps.get_version.outputs.VERSION }}
run: |
if [ ! -z "$THEMEISLE_ID" ]; then
STORE_JSON='{"version": "'$BUILD_VERSION'","id": "'$THEMEISLE_ID'","body": ""}';
echo "$STORE_JSON";
curl -X POST -H 'Cache-Control: no-cache' -H "Content-Type: application/json" -H "x-themeisle-auth: $THEMEISLE_AUTH" --data "$STORE_JSON" "$STORE_URL/wp-json/edd-so/v1/update_changelog/" > /dev/null
fi
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
uses: Codeinwp/action-store-release@main
8 changes: 5 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ module.exports = function (grunt) {
'use strict';
grunt.initConfig({
wp_readme_to_markdown: {
files: {
'readme.md': 'readme.txt'
plugin: {
files: {
'readme.md': 'readme.txt'
},
},
},
version: {
Expand Down Expand Up @@ -37,4 +39,4 @@ module.exports = function (grunt) {
});
grunt.loadNpmTasks('grunt-version');
grunt.loadNpmTasks('grunt-wp-readme-to-markdown');
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class MapSettings extends Component {
<li>
{ __( 'A continent or a sub-continent, specified by its 3-digit code, e.g., \'011\' for Western Africa. ' ) }
<ExternalLink
href="https://google-developers.appspot.com/chart/interactive/docs/gallery/geochart#Continent_Hierarchy"
href="https://developers.google.com/chart/interactive/docs/gallery/geochart#continent-hierarchy-and-codes"
>
{ __( 'More info here.' ) }
</ExternalLink>
Expand Down
2 changes: 1 addition & 1 deletion classes/Visualizer/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function _addAjaxAction( $tag, $method = '', $methodClass = null, $pri
*
* @access protected
* @param string $tag The name of the filter to hook the $method to.
* @param type $method The name of the method to be called when the filter is applied.
* @param string $method The name of the method to be called when the filter is applied.
* @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
* @param int $accepted_args optional. The number of arguments the function accept (default 1).
* @return Visualizer_Module
Expand Down
54 changes: 40 additions & 14 deletions classes/Visualizer/Module/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function __construct( Visualizer_Plugin $plugin ) {

$this->_addAction( 'admin_init', 'adminInit' );
$this->_addAction( 'init', 'setupCustomPostTypes' );
$this->_addFilter( 'cron_schedules', 'custom_cron_schedules' );
$this->_addAction( 'plugins_loaded', 'loadTextDomain' );
$this->_addFilter( 'visualizer_logger_data', 'getLoggerData' );
$this->_addFilter( 'visualizer_get_chart_counts', 'getUsage', 10, 2 );
Expand Down Expand Up @@ -209,7 +210,7 @@ public function activate( $network_wide ) {
*/
private function activate_on_site() {
wp_clear_scheduled_hook( 'visualizer_schedule_refresh_db' );
wp_schedule_event( strtotime( 'midnight' ) - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS, apply_filters( 'visualizer_chart_schedule_interval', 'hourly' ), 'visualizer_schedule_refresh_db' );
wp_schedule_event( strtotime( 'midnight' ) - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS, apply_filters( 'visualizer_chart_schedule_interval', 'visualizer_ten_minutes' ), 'visualizer_schedule_refresh_db' );
add_option( 'visualizer-activated', true );
$is_fresh_install = get_option( 'visualizer_fresh_install', false );
if ( ! defined( 'TI_CYPRESS_TESTING' ) && false === $is_fresh_install ) {
Expand Down Expand Up @@ -281,9 +282,9 @@ public function adminInit() {
/**
* Refresh the specific chart from the db.
*
* @param WP_Post $chart The chart object.
* @param int $chart_id The chart id.
* @param bool $force If this is true, then the chart data will be force refreshed. If false, data will be refreshed only if the chart requests live data.
* @param WP_Post|null $chart The chart object.
* @param int $chart_id The chart id.
* @param bool $force If this is true, then the chart data will be force refreshed. If false, data will be refreshed only if the chart requests live data.
*
* @access public
*/
Expand Down Expand Up @@ -391,38 +392,49 @@ public function refresh_db_for_chart( $chart, $chart_id, $force = false ) {
}

/**
* Refresh the db chart.
* Refresh the Database chart type.
*
* @access public
*/
public function refreshDbChart() {
$schedules = get_option( Visualizer_Plugin::CF_DB_SCHEDULE, array() );
if ( ! $schedules ) {
// NOTE: This use a different key from normal schedule. Updated only by Database chart. Check `visualizer_schedule_import` action.
$chart_schedules = get_option( Visualizer_Plugin::CF_DB_SCHEDULE, array() );
if ( ! $chart_schedules ) {
return;
}

if ( ! defined( 'VISUALIZER_DO_NOT_DIE' ) ) {
// define this so that the ajax call does not die
// this means that if the new version of pro and the old version of free are installed, only the first chart will be updated
define( 'VISUALIZER_DO_NOT_DIE', true );
}

$new_schedules = array();
$now = time();
foreach ( $schedules as $chart_id => $time ) {
$new_schedules[ $chart_id ] = $time;
if ( $time > $now ) {
$current_time = time();
foreach ( $chart_schedules as $chart_id => $scheduled_time ) {

// Skip deleted charts.
if ( false === get_post_status( $chart_id ) ) {
continue;
}

$new_schedules[ $chart_id ] = $scheduled_time;

// Should we do an update?
if ( $scheduled_time > $current_time ) {
continue;
}

// if the time is nigh, we force an update.
$this->refresh_db_for_chart( null, $chart_id, true );

// Clear existing chart cache.
$cache_key = Visualizer_Plugin::CF_CHART_CACHE . '_' . $chart_id;
if ( get_transient( $cache_key ) ) {
delete_transient( $cache_key );
}
$hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true );
$new_schedules[ $chart_id ] = time() + $hours * HOUR_IN_SECONDS;

$scheduled_hours = get_post_meta( $chart_id, Visualizer_Plugin::CF_DB_SCHEDULE, true );
$new_schedules[ $chart_id ] = $current_time + $scheduled_hours * HOUR_IN_SECONDS;
}
update_option( Visualizer_Plugin::CF_DB_SCHEDULE, $new_schedules );
}
Expand All @@ -443,4 +455,18 @@ public function checkIsExistingUser() {
}
}

/**
* Add custom cron schedules.
*
* @param array $schedules The current schedules options.
* @return array The modified schedules options.
*/
public function custom_cron_schedules( $schedules ) {
$schedules['visualizer_ten_minutes'] = array(
'interval' => 600,
'display' => __( 'Every 10 minutes', 'visualizer' ),
);

return $schedules;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected function _renderMapSettings() {
esc_html__( 'Configure the region area to display on the map. (Surrounding areas will be displayed as well.) Can be one of the following:', 'visualizer' ) .
'<ul>' .
'<li>' . esc_html__( "'world' - A map of the entire world.", 'visualizer' ) . '</li>' .
'<li>' . sprintf( esc_html__( "A continent or a sub-continent, specified by its %s code, e.g., '011' for Western Africa.", 'visualizer' ), '<a href="https://google-developers.appspot.com/chart/interactive/docs/gallery/geochart#Continent_Hierarchy" target="_blank">3-digit</a>' ) . '</li>' .
'<li>' . sprintf( esc_html__( "A continent or a sub-continent, specified by its %s code, e.g., '011' for Western Africa.", 'visualizer' ), '<a href="https://developers.google.com/chart/interactive/docs/gallery/geochart#continent-hierarchy-and-codes" target="_blank">3-digit</a>' ) . '</li>' .
'<li>' . sprintf( esc_html__( "A country, specified by its %s code, e.g., 'AU' for Australia.", 'visualizer' ), '<a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" target="_blank">ISO 3166-1 alpha-2</a>' ) . '</li>' .
'<li>' . sprintf( esc_html__( "A state in the United States, specified by its %s code, e.g., 'US-AL' for Alabama. Note that the resolution option must be set to either 'provinces' or 'metros'.", 'visualizer' ), '<a href="http://en.wikipedia.org/wiki/ISO_3166-2:US" target="_blank">ISO 3166-2:US</a>' ) . '</li>' .
'</ul>'
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aec1ac4

Please sign in to comment.