diff --git a/common/php/class-module.php b/common/php/class-module.php index 7e5cf723..cadb1b72 100644 --- a/common/php/class-module.php +++ b/common/php/class-module.php @@ -15,6 +15,10 @@ class EF_Module { 'private', ); + public $module_url; + + public $module; + function __construct() {} /** @@ -437,7 +441,7 @@ function timesince( $original ) { } } - return sprintf( _n( "1 $name ago", "$count ${name}s ago", $count), $count); + return sprintf( _n( "1 $name ago", "$count {$name}s ago", $count), $count); } /** diff --git a/edit_flow.php b/edit_flow.php index cfa7ed8a..77adf6a9 100644 --- a/edit_flow.php +++ b/edit_flow.php @@ -53,6 +53,7 @@ function _ef_print_php_version_admin_notice() { define( 'EDIT_FLOW_SETTINGS_PAGE' , add_query_arg( 'page', 'ef-settings', get_admin_url( null, 'admin.php' ) ) ); // Core class +#[\AllowDynamicProperties] class edit_flow { // Unique identified added as a prefix to all options @@ -64,6 +65,25 @@ class edit_flow { */ private static $instance; + /** + * Active modules. + * + * @var \stdClass + */ + public $modules; + + /** + * Number of active modules. + * + * @var int + */ + public $modules_count; + + /** + * @var EF_Module + */ + public $helpers; + /** * Main EditFlow Instance * diff --git a/modules/calendar/calendar.php b/modules/calendar/calendar.php index 8f9dc226..2d20b016 100644 --- a/modules/calendar/calendar.php +++ b/modules/calendar/calendar.php @@ -8,12 +8,12 @@ if ( !class_exists('EF_Calendar') ) { class EF_Calendar extends EF_Module { - + const usermeta_key_prefix = 'ef_calendar_'; const screen_id = 'dashboard_page_calendar'; - + var $module; - + var $start_date = ''; var $current_week = 1; var $total_weeks = 6; // default number of weeks to show per screen @@ -22,9 +22,11 @@ class EF_Calendar extends EF_Module { private $post_date_cache = array(); private static $post_li_html_cache_key = 'ef_calendar_post_li_html'; + private int $max_weeks; + private string $create_post_cap; /** - * Calendar published statuses are the same as other + * Calendar published statuses are the same as other * components but without the future */ public $published_statuses = array( @@ -37,7 +39,7 @@ class EF_Calendar extends EF_Module { */ function __construct() { $this->max_weeks = 12; - + $this->module_url = $this->get_module_url( __FILE__ ); // Register the module with Edit Flow $args = array( @@ -73,17 +75,17 @@ function __construct() { ), 'settings_help_sidebar' => __( '
For more information:
', 'edit-flow' ), ); - $this->module = EditFlow()->register_module( 'calendar', $args ); - + $this->module = EditFlow()->register_module( 'calendar', $args ); + } - + /** * Initialize all of our methods and such. Only runs if the module is active * * @uses add_action() */ function init() { - + // .ics calendar subscriptions add_action( 'wp_ajax_ef_calendar_ics_subscription', array( $this, 'handle_ics_subscription' ) ); add_action( 'wp_ajax_nopriv_ef_calendar_ics_subscription', array( $this, 'handle_ics_subscription' ) ); @@ -98,15 +100,15 @@ function init() { add_action( 'admin_init', array( $this, 'add_screen_options_panel' ) ); add_action( 'admin_init', array( $this, 'handle_save_screen_options' ) ); - + add_action( 'admin_init', array( $this, 'register_settings' ) ); add_action( 'admin_menu', array( $this, 'action_admin_menu' ) ); add_action( 'admin_print_styles', array( $this, 'add_admin_styles' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) ); - + // Ajax manipulation for the calendar add_action( 'wp_ajax_ef_calendar_drag_and_drop', array( $this, 'handle_ajax_drag_and_drop' ) ); - + // Ajax insert post placeholder for a specific date add_action( 'wp_ajax_ef_insert_post', array( $this, 'handle_ajax_insert_post' ) ); @@ -123,7 +125,7 @@ function init() { add_action( 'pre_post_update', array( $this, 'fix_post_date_on_update_part_one' ), 10, 2 ); add_action( 'post_updated', array( $this, 'fix_post_date_on_update_part_two' ), 10, 3 ); } - + /** * Load the capabilities onto users the first time the module is run * @@ -166,18 +168,18 @@ function upgrade( $previous_version ) { // Technically we've run this code before so we don't want to auto-install new data $edit_flow->update_module_option( $this->module->name, 'loaded_once', true ); } - + } - + /** * Add the calendar link underneath the "Dashboard" * * @uses add_submenu_page */ - function action_admin_menu() { + function action_admin_menu() { add_submenu_page('index.php', __('Calendar', 'edit-flow'), __('Calendar', 'edit-flow'), apply_filters( 'ef_view_calendar_cap', 'ef_view_calendar' ), $this->module->slug, array( $this, 'view_calendar' ) ); } - + /** * Add any necessary CSS to the WordPress admin * @@ -191,7 +193,7 @@ function add_admin_styles() { wp_enqueue_style( 'edit-flow-calendar-react-css', $this->module_url . 'lib/dist/calendar.react.style.build.css', array( 'wp-components' ), EDIT_FLOW_VERSION ); } } - + /** * Add any necessary JS to the WordPress admin * @@ -200,7 +202,7 @@ function add_admin_styles() { */ function enqueue_admin_scripts() { global $pagenow; - + if ( 'index.php' === $pagenow && isset( $_GET['page'] ) && 'calendar' === $_GET['page'] ) { $this->enqueue_datepicker_resources(); @@ -216,7 +218,7 @@ function enqueue_admin_scripts() { wp_enqueue_script( $js_library ); } wp_enqueue_script( 'edit-flow-calendar-js', $this->module_url . 'lib/calendar.js', $js_libraries, EDIT_FLOW_VERSION, true ); - + $ef_cal_js_params = array( 'can_add_posts' => current_user_can( $this->create_post_cap ) ? 'true' : 'false' ); wp_localize_script( 'edit-flow-calendar-js', 'ef_calendar_params', $ef_cal_js_params ); @@ -224,25 +226,25 @@ function enqueue_admin_scripts() { * Powering the new React interface */ wp_enqueue_script( 'edit-flow-calendar-react-js', $this->module_url . 'lib/dist/calendar.react.build.js', array( 'react', 'react-dom', 'wp-components', 'wp-url', 'wp-data', 'moment' ), EDIT_FLOW_VERSION, true ); - + wp_add_inline_script( 'edit-flow-calendar-react-js', 'var EF_CALENDAR = ' . wp_json_encode( $this->get_calendar_frontend_config() ), 'before' ); } - + } - + /** * Prepare the options that need to appear in Screen Options * * @since 0.7 - */ + */ function generate_screen_options() { - + $output = ''; - + $args = array( 'action' => 'ef_calendar_ics_subscription', 'user' => wp_get_current_user()->user_login, @@ -252,10 +254,10 @@ function generate_screen_options() { $output .= '@@ -843,9 +842,9 @@ function view_calendar() { $output = $this->generate_post_li_html( $post, $week_single_date, $num ); } echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped - } + } - } + } ?> hidden ): ?> @@ -858,14 +857,14 @@ function view_calendar() { @@ -873,22 +872,22 @@ function view_calendar() { |