-
- = sprintf( __( '%s encountered a fatal error and recovered successfully.', 'sermon-manager-for-wordpress' ), $plugin_name ) ?>
+
+ = wp_sprintf( esc_html__( '%s encountered a fatal error and recovered successfully.', 'sermon-manager-for-wordpress' ), '' . esc_html( $plugin_name . '' ) ) ?>
- = __( 'The issue has already been submitted.', 'sermon-manager-for-wordpress' ) ?>
+ = esc_html__( 'The issue has already been submitted.', 'sermon-manager-for-wordpress' ) ?>
- = _x( 'Send an anonymous report', 'Button', 'sermon-manager-for-wordpress' ) ?>
+ = esc_html_x( 'Send an anonymous report', 'Button', 'sermon-manager-for-wordpress' ) ?>
- = _x( 'Show error message', 'Button', 'sermon-manager-for-wordpress' ) ?>
+ = esc_html_x( 'Show error message', 'Button', 'sermon-manager-for-wordpress' ) ?>
- = _x( 'Reactivate Plugin', 'Button', 'sermon-manager-for-wordpress' ) ?>
+ = esc_html_x( 'Reactivate Plugin', 'Button', 'sermon-manager-for-wordpress' ) ?>
-
-
= __( 'If the issue is not fixed, website will crash. (but we will recover it again)', 'sermon-manager-for-wordpress' ) ?>
+
= esc_html__( 'If the issue is not fixed, website will crash. (but we will recover it again)', 'sermon-manager-for-wordpress' ) ?>
-
-
= __( 'If you have more information about the issue, please type it here (optional):', 'sermon-manager-for-wordpress' ) ?>
+
= esc_html__( 'If you have more information about the issue, please type it here (optional):', 'sermon-manager-for-wordpress' ) ?>
-
= __( 'Email for further contact (optional)', 'sermon-manager-for-wordpress' ) ?>
-
+ placeholder="= esc_attr_x( 'Steps for how to reproduce, etc…', 'Placeholder', 'sermon-manager-for-wordpress' ) ?>">
+
= esc_html__( 'Email for further contact (optional)', 'sermon-manager-for-wordpress' ) ?>
+
urlencode( str_replace( ABSPATH, '~/', get_option( '_sm_recovery_last_fatal_error' ) ) ),
- 'environment_info' => 'WordPress: ' . $GLOBALS['wp_version'] . '; Server: ' . ( function_exists( 'apache_get_version' ) ? apache_get_version() : 'N/A' ) . '; PHP: ' . PHP_VERSION . '; Sermon Manager:' . SERMON_MANAGER_VERSION . ';',
- 'plugin_name' => get_plugin_data( constant( self::$_plugin_main_file ) )['Name'],
+ 'environment_info' => 'WordPress: ' . $GLOBALS['wp_version'] . '; Server: ' . ( function_exists( 'apache_get_version' ) ? apache_get_version() : 'N/A' ) . '; PHP: ' . PHP_VERSION . '; Sermon Manager:' . SM_VERSION . ';',
+ 'plugin_name' => $plugin_data['Name'],
) );
- wp_enqueue_style( 'sm-error-recovery', SERMON_MANAGER_URL . 'css/error-recovery.css', array(), SERMON_MANAGER_VERSION );
+ wp_enqueue_style( 'sm-error-recovery', SM_URL . 'assets/css/error-recovery.css', array(), SM_VERSION );
}
/**
@@ -269,14 +282,9 @@ public static function disable_send_report_button() {
*/
public static function upgrade_check() {
$db_version = get_option( 'sm_version' );
- if ( empty( $db_version ) || $db_version != SERMON_MANAGER_VERSION ) {
+ if ( empty( $db_version ) || $db_version != SM_VERSION ) {
update_option( '_sm_recovery_do_not_catch', 0 );
update_option( '_sm_recovery_disable', 0 );
- update_option( 'sm_version', SERMON_MANAGER_VERSION );
-
- // Flush rewrite rules after update
- add_action( 'sm_after_register_post_type', array( 'SM_Post_Types', 'flush_rewrite_rules_hard' ) );
- add_action( 'sm_after_register_taxonomy', array( 'SM_Post_Types', 'flush_rewrite_rules_hard' ) );
}
}
@@ -310,4 +318,4 @@ private function _register_wp_hooks() {
add_action( 'wp_ajax_sm_clear_fatal_error', array( get_class(), 'reset_db' ) );
add_action( 'wp_ajax_sm_recovery_disable_send_report', array( get_class(), 'disable_send_report_button' ) );
}
-}
\ No newline at end of file
+}
diff --git a/includes/class-sm-install.php b/includes/class-sm-install.php
new file mode 100644
index 0000000..c0a69d1
--- /dev/null
+++ b/includes/class-sm-install.php
@@ -0,0 +1,195 @@
+ array(
+ 'sm_update_28_revert_old_dates',
+ 'sm_update_28_convert_dates_to_unix',
+ 'sm_update_28_fill_out_empty_dates',
+ 'sm_update_28_fill_out_series_dates',
+ 'sm_update_28_save_sermon_render_into_post_content',
+ 'sm_update_28_reset_recovery',
+ )
+ );
+
+ /** @var object Background update class */
+ private static $background_updater;
+
+ public static function init() {
+ add_action( 'init', array( __CLASS__, 'init_background_updater' ), 3 );
+ add_action( 'init', array( __CLASS__, 'check_version' ), 8 );
+ add_filter( 'plugin_action_links_' . SM_BASENAME, array( __CLASS__, 'plugin_action_links' ) );
+ add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 );
+ add_filter( 'cron_schedules', array( __CLASS__, 'cron_schedules' ) );
+ }
+
+ /**
+ * Check Sermon Manager version and run the updater is required
+ *
+ * This check is done on all requests and runs if the versions do not match
+ */
+ public static function check_version() {
+ if ( ! defined( 'IFRAME_REQUEST' ) && get_option( 'sm_version' ) !== SM_VERSION ) {
+ self::_install();
+ do_action( 'sm_updated' );
+ }
+ }
+
+ /**
+ * Install Sermon Manager
+ */
+ private static function _install() {
+ global $wpdb;
+
+ if ( ! is_blog_installed() ) {
+ return;
+ }
+
+ if ( ! defined( 'SM_INSTALLING' ) ) {
+ define( 'SM_INSTALLING', true );
+ }
+
+ //self::_create_options(); todo: will be done in future versions, every option will have its own field in the database, so we will just use `add_option()` - it won't overwrite the field
+ //self::_create_roles(); todo: will be done in future versions
+
+ // Register post types
+ SM_Post_types::register_post_types();
+ SM_Post_types::register_taxonomies();
+
+ // do update
+ self::_update();
+
+ // Update version just in case
+ self::update_db_version();
+
+ // Flush rules after install
+ do_action( 'sm_flush_rewrite_rules' );
+
+ /*
+ * Deletes all expired transients. The multi-table delete syntax is used
+ * to delete the transient record from table a, and the corresponding
+ * transient_timeout record from table b.
+ *
+ * Based on code inside core's upgrade_network() function.
+ */
+ /** @noinspection SqlNoDataSourceInspection */
+ $sql = "DELETE a, b FROM $wpdb->options a, $wpdb->options b
+ WHERE a.option_name LIKE %s
+ AND a.option_name NOT LIKE %s
+ AND b.option_name = CONCAT( '_transient_timeout_', SUBSTRING( a.option_name, 12 ) )
+ AND b.option_value < %d";
+ $wpdb->query( $wpdb->prepare( $sql, $wpdb->esc_like( '_transient_' ) . '%', $wpdb->esc_like( '_transient_timeout_' ) . '%', time() ) );
+
+ // Trigger action
+ do_action( 'sm_installed' );
+ }
+
+ /**
+ * Push all needed DB updates to the queue for processing.
+ */
+ private static function _update() {
+ $current_db_version = get_option( 'sm_version' );
+ $update_queued = false;
+
+ foreach ( self::_get_db_update_callbacks() as $version => $update_callbacks ) {
+ if ( version_compare( $current_db_version, $version, '<' ) ) {
+ foreach ( $update_callbacks as $update_callback ) {
+ self::$background_updater->push_to_queue( $update_callback );
+ $update_queued = true;
+ }
+ }
+ }
+
+ if ( $update_queued ) {
+ self::$background_updater->save()->dispatch();
+ }
+ }
+
+ /**
+ * Get list of DB update callbacks.
+ *
+ * @return array
+ */
+ private static function _get_db_update_callbacks() {
+ return self::$db_updates;
+ }
+
+ /**
+ * Init background updates
+ */
+ public static function init_background_updater() {
+ include_once 'class-sm-background-updater.php';
+ self::$background_updater = new SM_Background_Updater();
+ }
+
+ /**
+ * Update DB version to current.
+ *
+ * @param string $version (optional)
+ */
+ public static function update_db_version( $version = null ) {
+ delete_option( 'sm_version' );
+ add_option( 'sm_version', is_null( $version ) ? SM_VERSION : $version );
+ }
+
+ /**
+ * Add more cron schedules
+ *
+ * @param array $schedules
+ *
+ * @return array
+ */
+ public static function cron_schedules( $schedules ) {
+ $schedules['monthly'] = array(
+ 'interval' => 2635200,
+ 'display' => __( 'Monthly', 'sermon-manager-for-wordpress' ),
+ );
+
+ return $schedules;
+ }
+
+ /**
+ * Show action links on the plugin screen.
+ *
+ * @param mixed $links Plugin Action links
+ *
+ * @return array
+ */
+ public static function plugin_action_links( $links ) {
+ $action_links = array(
+ 'settings' => '