diff --git a/.gitignore b/.gitignore index ae1162a28..f1892e01e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules wordpress vendor +.vscode \ No newline at end of file diff --git a/common/php/class-module.php b/common/php/class-module.php index 0d7231d66..0fe1508f4 100644 --- a/common/php/class-module.php +++ b/common/php/class-module.php @@ -7,6 +7,7 @@ if ( !class_exists( 'EF_Module' ) ) { +#[\AllowDynamicProperties] class EF_Module { public $published_statuses = array( @@ -15,6 +16,8 @@ class EF_Module { 'private', ); + public $module_url; + function __construct() {} /** @@ -478,7 +481,7 @@ function users_select_form( $selected = null, $args = null ) {
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 +98,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 +123,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 +166,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 +191,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 +200,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 +216,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 +224,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 +252,10 @@ function generate_screen_options() { $output .= '@@ -843,9 +843,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 +858,14 @@ function view_calendar() { @@ -873,22 +873,22 @@ function view_calendar() { |