Skip to content

Commit

Permalink
Merge pull request #19 from firetreedesign/1.0.16
Browse files Browse the repository at this point in the history
Closes #18
  • Loading branch information
danielmilner committed Sep 8, 2020
2 parents 7627b97 + 3477def commit 8cc8b42
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 93 deletions.
140 changes: 71 additions & 69 deletions ft-rockpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: RockPress
* Plugin URI: https://rockpresswp.com/
* Description: Display information from Rock RMS on your WordPress site.
* Version: 1.0.15
* Version: 1.0.16
* Author: RockPress <support@rockpresswp.com>
* Author URI: https://rockpresswp.com/
* Text Domain: ft-rockpress
Expand All @@ -28,15 +28,15 @@
*/
class RockPress {

/**
* Instance
*
* @var RockPress The one true RockPress
* @since 1.0.0
*/
/**
* Instance
*
* @var RockPress The one true RockPress
* @since 1.0.0
*/
private static $instance;

/**
/**
* RockPress Transients Object
*
* @var object
Expand All @@ -45,11 +45,11 @@ class RockPress {
public $transients;

/**
* Rock Object
*
* @var object
* @since 1.0.0
*/
* Rock Object
*
* @var object
* @since 1.0.0
*/
public $rock;

/**
Expand All @@ -61,45 +61,45 @@ class RockPress {
public $get;

/**
* RockPress Version
*
* @var string
* @since 1.0.0
*/
public $version = '1.0.15';
* RockPress Version
*
* @var string
* @since 1.0.0
*/
public $version = '1.0.15';

/**
* Main RockPress Instance
*
* Insures that only one instance of RockPress exists in memory at any
* one time.
*
* @since 1.0
* @static
* @staticvar array $instance
* @uses RockPress::includes() Include the required files
* @see RockPress()
* @return The one true RockPress
*/
public static function instance() {

if ( ! isset( self::$instance ) && ! ( self::$instance instanceof RockPress ) ) {

self::$instance = new RockPress;
self::$instance->setup_constants();
self::$instance->includes();
* Main RockPress Instance
*
* Insures that only one instance of RockPress exists in memory at any
* one time.
*
* @since 1.0
* @static
* @staticvar array $instance
* @uses RockPress::includes() Include the required files
* @see RockPress()
* @return The one true RockPress
*/
public static function instance() {

if ( ! isset( self::$instance ) && ! ( self::$instance instanceof RockPress ) ) {

self::$instance = new RockPress();
self::$instance->setup_constants();
self::$instance->includes();
self::$instance->actions();
self::$instance->register_addon();

self::$instance->transients = new RockPress_Transients();
self::$instance->rock = new RockPress_Rock_REST_API();
self::$instance->get = new RockPress_Background_Get();
self::$instance->transients = new RockPress_Transients();
self::$instance->rock = new RockPress_Rock_REST_API();
self::$instance->get = new RockPress_Background_Get();

}
}

return self::$instance;
return self::$instance;

}
}

/**
* Setup plugin constants
Expand All @@ -111,21 +111,21 @@ public static function instance() {
private function setup_constants() {

// Plugin Version.
if ( ! defined( 'ROCKPRESS_VERSION' ) ) {
define( 'ROCKPRESS_VERSION', $this->version );
}
if ( ! defined( 'ROCKPRESS_VERSION' ) ) {
define( 'ROCKPRESS_VERSION', $this->version );
}

// Plugin File.
if ( ! defined( 'ROCKPRESS_PLUGIN_FILE' ) ) {
define( 'ROCKPRESS_PLUGIN_FILE', __FILE__ );
}
if ( ! defined( 'ROCKPRESS_PLUGIN_FILE' ) ) {
define( 'ROCKPRESS_PLUGIN_FILE', __FILE__ );
}

// Plugin Folder Path.
if ( ! defined( 'ROCKPRESS_PLUGIN_DIR' ) ) {
define( 'ROCKPRESS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}
// Plugin Folder Path.
if ( ! defined( 'ROCKPRESS_PLUGIN_DIR' ) ) {
define( 'ROCKPRESS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
}

// Plugin Folder URL.
// Plugin Folder URL.
if ( ! defined( 'ROCKPRESS_PLUGIN_URL' ) ) {
define( 'ROCKPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
Expand All @@ -141,11 +141,13 @@ private function setup_constants() {
*/
private function register_addon() {

$addon = new RockPress_Addon( array(
'controllers' => array(
'Campuses',
),
) );
$addon = new RockPress_Addon(
array(
'controllers' => array(
'Campuses',
),
)
);

}

Expand All @@ -159,16 +161,16 @@ private function register_addon() {
private function includes() {

require_once ROCKPRESS_PLUGIN_DIR . 'includes/class-rockpress-transients.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/class-rockpress-rest-api.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/class-rockpress-rest-api.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/class-rockpress-licenses.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/class-rockpress-addon.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/class-rockpress-options.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/class-rockpress-customizer.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/class-rockpress-blocks.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/admin-settings.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/settings/settings-rock.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/admin-settings.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/settings/settings-rock.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/settings/settings-import.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/settings/settings-rockpress.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/settings/settings-rockpress.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/settings/settings-licenses.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/admin-ajax.php';
require_once ROCKPRESS_PLUGIN_DIR . 'lib/wp-background-processing/wp-async-request.php';
Expand All @@ -179,16 +181,16 @@ private function includes() {
require_once ROCKPRESS_PLUGIN_DIR . 'includes/widgets/widget-service-times.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/widgets/widget-campus-selector.php';

if ( is_admin() ) {
if ( is_admin() ) {
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/admin-page-tabs.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/admin-pages.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/admin-scripts.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/admin-scripts.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/admin-styles.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php';
require_once ROCKPRESS_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-generator.php';
}
}

}
}

/**
* Actions
Expand All @@ -210,7 +212,7 @@ private function actions() {
* @return void
*/
public function register_styles() {
wp_register_style( 'rockpress', ROCKPRESS_PLUGIN_URL . 'assets/css/display.css' );
wp_register_style( 'rockpress', ROCKPRESS_PLUGIN_URL . 'assets/css/display.css', array(), ROCKPRESS_VERSION );
}

/**
Expand Down
56 changes: 34 additions & 22 deletions includes/class-rockpress-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* RockPress - Import
*
* @since 0.2.0
* @package RockPress
* @since 0.2.0
* @package RockPress
*/

// Exit if accessed directly.
Expand All @@ -24,14 +24,14 @@ class RockPress_Import {
* @return void
*/
public static function init() {
add_action( 'rockpress_maintenance', __CLASS__ . '::run' );
add_action( 'rockpress_import_job_queued', __CLASS__ . '::import_job_queued' );
add_action( 'rockpress_import_jobs_dispatched', __CLASS__ . '::import_jobs_dispatched' );
add_action( 'rockpress_background_get_complete', __CLASS__ . '::import_complete', 1000 );
add_action( 'wp_ajax_rockpress_import', __CLASS__ . '::ajax_run' );
add_action( 'wp_ajax_rockpress_import_status', __CLASS__ . '::ajax_status' );
add_action( 'wp_ajax_rockpress_last_import', __CLASS__ . '::ajax_last_import' );
add_action( 'wp_ajax_rockpress_reset_import', __CLASS__ . '::ajax_reset_import' );
add_action( 'rockpress_maintenance', __CLASS__ . '::run' );
add_action( 'rockpress_import_job_queued', __CLASS__ . '::import_job_queued' );
add_action( 'rockpress_import_jobs_dispatched', __CLASS__ . '::import_jobs_dispatched' );
add_action( 'rockpress_background_get_complete', __CLASS__ . '::import_complete', 1000 );
add_action( 'wp_ajax_rockpress_import', __CLASS__ . '::ajax_run' );
add_action( 'wp_ajax_rockpress_import_status', __CLASS__ . '::ajax_status' );
add_action( 'wp_ajax_rockpress_last_import', __CLASS__ . '::ajax_last_import' );
add_action( 'wp_ajax_rockpress_reset_import', __CLASS__ . '::ajax_reset_import' );

}

Expand Down Expand Up @@ -124,7 +124,7 @@ public static function import_complete() {
*/
public static function ajax_run() {

if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'rockpress-nonce' ) ) {
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'rockpress-nonce' ) ) {
die( esc_html__( 'Insufficient Permissions', 'ft-rockpress' ) );
}

Expand All @@ -144,25 +144,31 @@ public static function ajax_run() {
*/
public static function ajax_status() {

if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'rockpress-nonce' ) ) {
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'rockpress-nonce' ) ) {
die( esc_html__( 'Insufficient Permissions', 'ft-rockpress' ) );
}

$status = array();
$status = array();
$progress = get_option( 'rockpress_import_in_progress', false );

if ( false === $progress ) {
wp_send_json( 'false' );
}

array_push( $status, array(
'text' => $progress,
'element' => 'strong',
) );
array_push( $status, array(
'text' => esc_html__( 'Import is running in the background. Leaving this page will not interrupt the process.', 'ft-rockpress' ),
'element' => 'i',
) );
array_push(
$status,
array(
'text' => $progress,
'element' => 'strong',
)
);
array_push(
$status,
array(
'text' => esc_html__( 'Import is running in the background. Leaving this page will not interrupt the process.', 'ft-rockpress' ),
'element' => 'i',
)
);

wp_send_json( $status );

Expand All @@ -177,7 +183,7 @@ public static function ajax_status() {
*/
public static function ajax_last_import() {

if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'rockpress-nonce' ) ) {
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'rockpress-nonce' ) ) {
die( esc_html__( 'Insufficient Permissions', 'ft-rockpress' ) );
}

Expand All @@ -198,6 +204,12 @@ public static function ajax_last_import() {
* @return void
*/
public static function ajax_reset_import() {
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'rockpress-nonce' ) ) {
die( esc_html__( 'Insufficient Permissions', 'ft-rockpress' ) );
}

delete_option( 'rockpress_import_in_progress' );
delete_option( 'rockpress_current_import' );
delete_option( 'rockpress_last_import' );
esc_html_e( 'Never', 'rockpress' );
wp_die();
Expand Down
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Contributors: firetree, danielmilner
Tags: church, rockrms, chms, rock rms
Requires at least: 4.3
Tested up to: 5.4
Tested up to: 5.5
Requires PHP: 5.3
Stable tag: 1.0.15
Stable tag: 1.0.16
License: GPLv2 or later
License URI: http://ww.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -41,6 +41,9 @@ Extend the capabilities of RockPress with these add-ons:

== Changelog ==

= 1.0.16 =
* Fixed an issue when resetting an import.

= 1.0.15 =
* Miscellaneous bug fixes.

Expand Down

0 comments on commit 8cc8b42

Please sign in to comment.