@@ -28,356 +28,356 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | class Wordlift_Admin { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * The ID of this plugin. |
|
| 33 | - * |
|
| 34 | - * @since 1.0.0 |
|
| 35 | - * @access private |
|
| 36 | - * @var string $plugin_name The ID of this plugin. |
|
| 37 | - */ |
|
| 38 | - private $plugin_name; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * The version of this plugin. |
|
| 42 | - * |
|
| 43 | - * @since 1.0.0 |
|
| 44 | - * @access private |
|
| 45 | - * @var string $version The current version of this plugin. |
|
| 46 | - */ |
|
| 47 | - private $version; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * The {@link Wordlift_Configuration_Service} instance. |
|
| 51 | - * |
|
| 52 | - * @since 3.14.0 |
|
| 53 | - * @access private |
|
| 54 | - * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance. |
|
| 55 | - */ |
|
| 56 | - private $configuration_service; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * The {@link Wordlift_User_Service} instance. |
|
| 60 | - * |
|
| 61 | - * @since 3.14.0 |
|
| 62 | - * @access private |
|
| 63 | - * @var \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
| 64 | - */ |
|
| 65 | - private $user_service; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * The {@link Wordlift_Batch_Operation_Ajax_Adapter} instance. |
|
| 69 | - * |
|
| 70 | - * @since 3.20.0 |
|
| 71 | - * @access private |
|
| 72 | - * @var \Wordlift_Batch_Operation_Ajax_Adapter $sync_batch_operation_ajax_adapter The {@link Wordlift_Batch_Operation_Ajax_Adapter} instance. |
|
| 73 | - */ |
|
| 74 | - private $sync_batch_operation_ajax_adapter; |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * The singleton instance. |
|
| 78 | - * |
|
| 79 | - * @since 3.19.4 |
|
| 80 | - * @access private |
|
| 81 | - * @var Wordlift_Admin $instance The singleton instance. |
|
| 82 | - */ |
|
| 83 | - private static $instance; |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Initialize the class and set its properties. |
|
| 87 | - * |
|
| 88 | - * @param string $plugin_name The name of this plugin. |
|
| 89 | - * @param string $version The version of this plugin. |
|
| 90 | - * @param \Wordlift_Configuration_Service $configuration_service The configuration service. |
|
| 91 | - * @param \Wordlift_Notice_Service $notice_service The notice service. |
|
| 92 | - * @param \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
| 93 | - * |
|
| 94 | - * @since 1.0.0 |
|
| 95 | - * |
|
| 96 | - */ |
|
| 97 | - public function __construct( $plugin_name, $version, $configuration_service, $notice_service, $user_service ) { |
|
| 98 | - |
|
| 99 | - $this->plugin_name = $plugin_name; |
|
| 100 | - $this->version = $version; |
|
| 101 | - |
|
| 102 | - $this->configuration_service = $configuration_service; |
|
| 103 | - $this->user_service = $user_service; |
|
| 104 | - |
|
| 105 | - $dataset_uri = $configuration_service->get_dataset_uri(); |
|
| 106 | - $key = $configuration_service->get_key(); |
|
| 107 | - |
|
| 108 | - if ( empty( $dataset_uri ) ) { |
|
| 109 | - $settings_page = Wordlift_Admin_Settings_Page::get_instance(); |
|
| 110 | - if ( empty( $key ) ) { |
|
| 111 | - $error = sprintf( esc_html__( "WordLift's key isn't set, please open the %s to set WordLift's key.", 'wordlift' ), '<a href="' . $settings_page->get_url() . '">' . esc_html__( 'settings page', 'wordlift' ) . '</a>' ); |
|
| 112 | - } else { |
|
| 113 | - $error = sprintf( esc_html__( "WordLift's dataset URI is not configured: please open the %s to set WordLift's key again.", 'wordlift' ), '<a href="' . $settings_page->get_url() . '">' . esc_html__( 'settings page', 'wordlift' ) . '</a>' ); |
|
| 114 | - } |
|
| 115 | - $notice_service->add_error( $error ); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - // Load additional code if we're in the admin UI. |
|
| 119 | - if ( is_admin() ) { |
|
| 120 | - |
|
| 121 | - // Require the PHP files for the next code fragment. |
|
| 122 | - self::require_files(); |
|
| 123 | - |
|
| 124 | - /* |
|
| 31 | + /** |
|
| 32 | + * The ID of this plugin. |
|
| 33 | + * |
|
| 34 | + * @since 1.0.0 |
|
| 35 | + * @access private |
|
| 36 | + * @var string $plugin_name The ID of this plugin. |
|
| 37 | + */ |
|
| 38 | + private $plugin_name; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * The version of this plugin. |
|
| 42 | + * |
|
| 43 | + * @since 1.0.0 |
|
| 44 | + * @access private |
|
| 45 | + * @var string $version The current version of this plugin. |
|
| 46 | + */ |
|
| 47 | + private $version; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * The {@link Wordlift_Configuration_Service} instance. |
|
| 51 | + * |
|
| 52 | + * @since 3.14.0 |
|
| 53 | + * @access private |
|
| 54 | + * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance. |
|
| 55 | + */ |
|
| 56 | + private $configuration_service; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * The {@link Wordlift_User_Service} instance. |
|
| 60 | + * |
|
| 61 | + * @since 3.14.0 |
|
| 62 | + * @access private |
|
| 63 | + * @var \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
| 64 | + */ |
|
| 65 | + private $user_service; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * The {@link Wordlift_Batch_Operation_Ajax_Adapter} instance. |
|
| 69 | + * |
|
| 70 | + * @since 3.20.0 |
|
| 71 | + * @access private |
|
| 72 | + * @var \Wordlift_Batch_Operation_Ajax_Adapter $sync_batch_operation_ajax_adapter The {@link Wordlift_Batch_Operation_Ajax_Adapter} instance. |
|
| 73 | + */ |
|
| 74 | + private $sync_batch_operation_ajax_adapter; |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * The singleton instance. |
|
| 78 | + * |
|
| 79 | + * @since 3.19.4 |
|
| 80 | + * @access private |
|
| 81 | + * @var Wordlift_Admin $instance The singleton instance. |
|
| 82 | + */ |
|
| 83 | + private static $instance; |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Initialize the class and set its properties. |
|
| 87 | + * |
|
| 88 | + * @param string $plugin_name The name of this plugin. |
|
| 89 | + * @param string $version The version of this plugin. |
|
| 90 | + * @param \Wordlift_Configuration_Service $configuration_service The configuration service. |
|
| 91 | + * @param \Wordlift_Notice_Service $notice_service The notice service. |
|
| 92 | + * @param \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
| 93 | + * |
|
| 94 | + * @since 1.0.0 |
|
| 95 | + * |
|
| 96 | + */ |
|
| 97 | + public function __construct( $plugin_name, $version, $configuration_service, $notice_service, $user_service ) { |
|
| 98 | + |
|
| 99 | + $this->plugin_name = $plugin_name; |
|
| 100 | + $this->version = $version; |
|
| 101 | + |
|
| 102 | + $this->configuration_service = $configuration_service; |
|
| 103 | + $this->user_service = $user_service; |
|
| 104 | + |
|
| 105 | + $dataset_uri = $configuration_service->get_dataset_uri(); |
|
| 106 | + $key = $configuration_service->get_key(); |
|
| 107 | + |
|
| 108 | + if ( empty( $dataset_uri ) ) { |
|
| 109 | + $settings_page = Wordlift_Admin_Settings_Page::get_instance(); |
|
| 110 | + if ( empty( $key ) ) { |
|
| 111 | + $error = sprintf( esc_html__( "WordLift's key isn't set, please open the %s to set WordLift's key.", 'wordlift' ), '<a href="' . $settings_page->get_url() . '">' . esc_html__( 'settings page', 'wordlift' ) . '</a>' ); |
|
| 112 | + } else { |
|
| 113 | + $error = sprintf( esc_html__( "WordLift's dataset URI is not configured: please open the %s to set WordLift's key again.", 'wordlift' ), '<a href="' . $settings_page->get_url() . '">' . esc_html__( 'settings page', 'wordlift' ) . '</a>' ); |
|
| 114 | + } |
|
| 115 | + $notice_service->add_error( $error ); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + // Load additional code if we're in the admin UI. |
|
| 119 | + if ( is_admin() ) { |
|
| 120 | + |
|
| 121 | + // Require the PHP files for the next code fragment. |
|
| 122 | + self::require_files(); |
|
| 123 | + |
|
| 124 | + /* |
|
| 125 | 125 | * @since 3.24.2 This function isn't called anymore because it was causing the Block Category to |
| 126 | 126 | * multiply in Block Editor. |
| 127 | 127 | * |
| 128 | 128 | * @see https://github.com/insideout10/wordlift-plugin/issues/1004 |
| 129 | 129 | */ |
| 130 | - // Add Wordlift custom block category. |
|
| 131 | - // self::add_block_category(); |
|
| 130 | + // Add Wordlift custom block category. |
|
| 131 | + // self::add_block_category(); |
|
| 132 | 132 | |
| 133 | - new Wordlift_Dashboard_Latest_News(); |
|
| 133 | + new Wordlift_Dashboard_Latest_News(); |
|
| 134 | 134 | |
| 135 | - // Search Rankings. |
|
| 136 | - $search_rankings_service = new Wordlift_Admin_Search_Rankings_Service( Wordlift_Api_Service::get_instance() ); |
|
| 137 | - new Wordlift_Admin_Search_Rankings_Ajax_Adapter( $search_rankings_service ); |
|
| 135 | + // Search Rankings. |
|
| 136 | + $search_rankings_service = new Wordlift_Admin_Search_Rankings_Service( Wordlift_Api_Service::get_instance() ); |
|
| 137 | + new Wordlift_Admin_Search_Rankings_Ajax_Adapter( $search_rankings_service ); |
|
| 138 | 138 | |
| 139 | - /* |
|
| 139 | + /* |
|
| 140 | 140 | * Add support for `All Entity Types`. |
| 141 | 141 | * |
| 142 | 142 | * @since 3.20.0 |
| 143 | 143 | * |
| 144 | 144 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 145 | 145 | */ |
| 146 | - if ( WL_ALL_ENTITY_TYPES ) { |
|
| 147 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-schemaorg-taxonomy-metabox.php'; |
|
| 148 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-schemaorg-property-metabox.php'; |
|
| 146 | + if ( WL_ALL_ENTITY_TYPES ) { |
|
| 147 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-schemaorg-taxonomy-metabox.php'; |
|
| 148 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-schemaorg-property-metabox.php'; |
|
| 149 | 149 | |
| 150 | - // new Wordlift_Admin_Schemaorg_Property_Metabox( Wordlift_Schemaorg_Property_Service::get_instance() ); |
|
| 151 | - /* |
|
| 150 | + // new Wordlift_Admin_Schemaorg_Property_Metabox( Wordlift_Schemaorg_Property_Service::get_instance() ); |
|
| 151 | + /* |
|
| 152 | 152 | * The `Mappings` admin page. |
| 153 | 153 | */ |
| 154 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-mappings-page.php'; |
|
| 155 | - new Wordlift_Admin_Mappings_Page(); |
|
| 154 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-mappings-page.php'; |
|
| 155 | + new Wordlift_Admin_Mappings_Page(); |
|
| 156 | 156 | |
| 157 | - /* |
|
| 157 | + /* |
|
| 158 | 158 | * Allow sync'ing the schema.org taxonomy with the schema.org json file. |
| 159 | 159 | * |
| 160 | 160 | * @since 3.20.0 |
| 161 | 161 | */ |
| 162 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-batch-operation.php'; |
|
| 162 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-batch-operation.php'; |
|
| 163 | 163 | |
| 164 | - $this->sync_batch_operation_ajax_adapter = new Wordlift_Batch_Operation_Ajax_Adapter( new Wordlift_Schemaorg_Sync_Batch_Operation(), 'wl_schemaorg_sync' ); |
|
| 164 | + $this->sync_batch_operation_ajax_adapter = new Wordlift_Batch_Operation_Ajax_Adapter( new Wordlift_Schemaorg_Sync_Batch_Operation(), 'wl_schemaorg_sync' ); |
|
| 165 | 165 | |
| 166 | - } |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - /* |
|
| 168 | + /* |
|
| 169 | 169 | * Add the {@link Wordlift_Admin_Term_Adapter}. |
| 170 | 170 | * |
| 171 | 171 | * @since 3.20.0 |
| 172 | 172 | */ |
| 173 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-term-adapter.php'; |
|
| 174 | - new Wordlift_Admin_Term_Adapter(); |
|
| 173 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-term-adapter.php'; |
|
| 174 | + new Wordlift_Admin_Term_Adapter(); |
|
| 175 | 175 | |
| 176 | - /* |
|
| 176 | + /* |
|
| 177 | 177 | * The new dashboard. |
| 178 | 178 | * |
| 179 | 179 | * @since 3.20.0 |
| 180 | 180 | * |
| 181 | 181 | * @see https://github.com/insideout10/wordlift-plugin/issues/879 |
| 182 | 182 | */ |
| 183 | - new Wordlift_Admin_Dashboard_V2( |
|
| 184 | - $search_rankings_service, |
|
| 185 | - Wordlift::get_instance()->get_dashboard_service(), |
|
| 186 | - Wordlift_Entity_Service::get_instance() |
|
| 187 | - ); |
|
| 188 | - new Wordlift_Admin_Not_Enriched_Filter(); |
|
| 189 | - |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - // @@todo only load this class if ACF is available. |
|
| 193 | - // Add support for ACF mappings, so that the admin edit mappings page can pick up ACF support when ACF is available. |
|
| 194 | - new Acf_Mappings(); |
|
| 195 | - |
|
| 196 | - // Add the Mappings' REST Controller. |
|
| 197 | - new Mappings_REST_Controller(); |
|
| 198 | - |
|
| 199 | - // Only enable the Mappings UI if the constant is defined. |
|
| 200 | - if ( defined( 'WL_ENABLE_MAPPINGS' ) && WL_ENABLE_MAPPINGS ) { |
|
| 201 | - // Add Mappings and Edit Mappings page. |
|
| 202 | - new Admin_Mappings_Page(); |
|
| 203 | - new Edit_Mappings_Page( new Mappings_Transform_Functions_Registry() ); |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - // Set the singleton instance. |
|
| 207 | - self::$instance = $this; |
|
| 208 | - |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * Get the singleton instance. |
|
| 213 | - * |
|
| 214 | - * @return \Wordlift_Admin The singleton instance. |
|
| 215 | - * @since 3.19.4 |
|
| 216 | - * |
|
| 217 | - */ |
|
| 218 | - public static function get_instance() { |
|
| 219 | - |
|
| 220 | - return self::$instance; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * Register the stylesheets for the admin area. |
|
| 225 | - * |
|
| 226 | - * @since 1.0.0 |
|
| 227 | - */ |
|
| 228 | - public function enqueue_styles() { |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * This function is provided for demonstration purposes only. |
|
| 232 | - * |
|
| 233 | - * An instance of this class should be passed to the run() function |
|
| 234 | - * defined in Wordlift_Loader as all of the hooks are defined |
|
| 235 | - * in that particular class. |
|
| 236 | - * |
|
| 237 | - * The Wordlift_Loader will then create the relationship |
|
| 238 | - * between the defined hooks and the functions defined in this |
|
| 239 | - * class. |
|
| 240 | - */ |
|
| 241 | - |
|
| 242 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-admin.css', array(), $this->version, 'all' ); |
|
| 243 | - |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - /** |
|
| 247 | - * Register the JavaScript for the admin area. |
|
| 248 | - * |
|
| 249 | - * @since 1.0.0 |
|
| 250 | - */ |
|
| 251 | - public function enqueue_scripts() { |
|
| 252 | - |
|
| 253 | - /* |
|
| 183 | + new Wordlift_Admin_Dashboard_V2( |
|
| 184 | + $search_rankings_service, |
|
| 185 | + Wordlift::get_instance()->get_dashboard_service(), |
|
| 186 | + Wordlift_Entity_Service::get_instance() |
|
| 187 | + ); |
|
| 188 | + new Wordlift_Admin_Not_Enriched_Filter(); |
|
| 189 | + |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + // @@todo only load this class if ACF is available. |
|
| 193 | + // Add support for ACF mappings, so that the admin edit mappings page can pick up ACF support when ACF is available. |
|
| 194 | + new Acf_Mappings(); |
|
| 195 | + |
|
| 196 | + // Add the Mappings' REST Controller. |
|
| 197 | + new Mappings_REST_Controller(); |
|
| 198 | + |
|
| 199 | + // Only enable the Mappings UI if the constant is defined. |
|
| 200 | + if ( defined( 'WL_ENABLE_MAPPINGS' ) && WL_ENABLE_MAPPINGS ) { |
|
| 201 | + // Add Mappings and Edit Mappings page. |
|
| 202 | + new Admin_Mappings_Page(); |
|
| 203 | + new Edit_Mappings_Page( new Mappings_Transform_Functions_Registry() ); |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + // Set the singleton instance. |
|
| 207 | + self::$instance = $this; |
|
| 208 | + |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * Get the singleton instance. |
|
| 213 | + * |
|
| 214 | + * @return \Wordlift_Admin The singleton instance. |
|
| 215 | + * @since 3.19.4 |
|
| 216 | + * |
|
| 217 | + */ |
|
| 218 | + public static function get_instance() { |
|
| 219 | + |
|
| 220 | + return self::$instance; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * Register the stylesheets for the admin area. |
|
| 225 | + * |
|
| 226 | + * @since 1.0.0 |
|
| 227 | + */ |
|
| 228 | + public function enqueue_styles() { |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * This function is provided for demonstration purposes only. |
|
| 232 | + * |
|
| 233 | + * An instance of this class should be passed to the run() function |
|
| 234 | + * defined in Wordlift_Loader as all of the hooks are defined |
|
| 235 | + * in that particular class. |
|
| 236 | + * |
|
| 237 | + * The Wordlift_Loader will then create the relationship |
|
| 238 | + * between the defined hooks and the functions defined in this |
|
| 239 | + * class. |
|
| 240 | + */ |
|
| 241 | + |
|
| 242 | + wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-admin.css', array(), $this->version, 'all' ); |
|
| 243 | + |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + /** |
|
| 247 | + * Register the JavaScript for the admin area. |
|
| 248 | + * |
|
| 249 | + * @since 1.0.0 |
|
| 250 | + */ |
|
| 251 | + public function enqueue_scripts() { |
|
| 252 | + |
|
| 253 | + /* |
|
| 254 | 254 | * Do not load our scripts on the Filter Urls plugin admin pages. |
| 255 | 255 | * |
| 256 | 256 | * @see https://github.com/insideout10/wordlift-plugin/issues/901 |
| 257 | 257 | * @since 3.20.0 |
| 258 | 258 | */ |
| 259 | - $screen = get_current_screen(); |
|
| 260 | - if ( is_a( $screen, 'WP_Screen' ) && 'filter-urls_page_filter_urls_form' === $screen->id ) { |
|
| 261 | - return; |
|
| 262 | - } |
|
| 259 | + $screen = get_current_screen(); |
|
| 260 | + if ( is_a( $screen, 'WP_Screen' ) && 'filter-urls_page_filter_urls_form' === $screen->id ) { |
|
| 261 | + return; |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - // Enqueue the admin scripts. |
|
| 265 | - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/1/admin.js', array( |
|
| 266 | - 'jquery', |
|
| 267 | - 'underscore', |
|
| 268 | - 'backbone', |
|
| 269 | - ), $this->version, false ); |
|
| 264 | + // Enqueue the admin scripts. |
|
| 265 | + wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/1/admin.js', array( |
|
| 266 | + 'jquery', |
|
| 267 | + 'underscore', |
|
| 268 | + 'backbone', |
|
| 269 | + ), $this->version, false ); |
|
| 270 | 270 | |
| 271 | 271 | |
| 272 | - $can_edit_wordlift_entities = current_user_can( 'edit_wordlift_entities' ); |
|
| 272 | + $can_edit_wordlift_entities = current_user_can( 'edit_wordlift_entities' ); |
|
| 273 | 273 | |
| 274 | - /* |
|
| 274 | + /* |
|
| 275 | 275 | * People that can create entities will see the scope set in the wp-config.php file (by default `cloud`). People |
| 276 | 276 | * that cannot edit create entities will always see the local entities. |
| 277 | 277 | * |
| 278 | 278 | * @see https://github.com/insideout10/wordlift-plugin/issues/839 |
| 279 | 279 | */ |
| 280 | - $autocomplete_scope = $can_edit_wordlift_entities ? WL_AUTOCOMPLETE_SCOPE : "local"; |
|
| 281 | - |
|
| 282 | - // Set the basic params. |
|
| 283 | - $params = array( |
|
| 284 | - // @todo scripts in admin should use wp.post. |
|
| 285 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 286 | - // @todo remove specific actions from settings. |
|
| 287 | - 'action' => 'entity_by_title', |
|
| 288 | - 'datasetUri' => $this->configuration_service->get_dataset_uri(), |
|
| 289 | - 'language' => $this->configuration_service->get_language_code(), |
|
| 290 | - 'link_by_default' => $this->configuration_service->is_link_by_default(), |
|
| 291 | - // Whether the current user is allowed to create new entities. |
|
| 292 | - // |
|
| 293 | - // @see https://github.com/insideout10/wordlift-plugin/issues/561 |
|
| 294 | - 'can_create_entities' => $can_edit_wordlift_entities ? 'yes' : 'no', |
|
| 295 | - 'l10n' => array( |
|
| 296 | - 'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ), |
|
| 297 | - 'logo_selection_title' => __( 'WordLift Choose Logo', 'wordlift' ), |
|
| 298 | - 'logo_selection_button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ), |
|
| 299 | - 'Type at least 3 characters to search...' => _x( 'Type at least 3 characters to search...', 'Autocomplete Select', 'wordlift' ), |
|
| 300 | - 'No results found for your search.' => _x( 'No results found: try changing or removing some words.', 'Autocomplete Select', 'wordlift' ), |
|
| 301 | - 'Please wait while we look for entities in the linked data cloud...' => _x( 'Please wait while we look for entities in the linked data cloud...', 'Autocomplete Select', 'wordlift' ), |
|
| 302 | - 'Add keywords to track' => __( 'Add Keywords to track', 'wordlift' ), |
|
| 303 | - ), |
|
| 304 | - 'wl_autocomplete_nonce' => wp_create_nonce( 'wl_autocomplete' ), |
|
| 305 | - 'autocomplete_scope' => $autocomplete_scope, |
|
| 306 | - /** |
|
| 307 | - * Allow 3rd parties to define the default editor id. This turns useful if 3rd parties load |
|
| 308 | - * or change the TinyMCE id. |
|
| 309 | - * |
|
| 310 | - * The editor id is currently referenced by `src/coffee/editpost-widget/app.services.EditorAdapter.coffee`. |
|
| 311 | - * |
|
| 312 | - * @param string $editor The default editor id, by default `content`. |
|
| 313 | - * |
|
| 314 | - * @see https://github.com/insideout10/wordlift-plugin/issues/848 |
|
| 315 | - * |
|
| 316 | - * @since 3.19.4 |
|
| 317 | - * |
|
| 318 | - */ |
|
| 319 | - 'default_editor_id' => apply_filters( 'wl_default_editor_id', 'content' ), |
|
| 320 | - /** |
|
| 321 | - * Add the link to the Search Keywords admin page. |
|
| 322 | - * |
|
| 323 | - * @since 3.20.0 |
|
| 324 | - */ |
|
| 325 | - 'search_keywords_admin_page' => admin_url( 'admin.php?page=wl_configuration_admin_menu&tab=search-keywords' ), |
|
| 326 | - |
|
| 327 | - 'analysis' => array( '_wpnonce' => wp_create_nonce( 'wl_analyze' ), ) |
|
| 328 | - ); |
|
| 329 | - |
|
| 330 | - // Set post-related values if there's a current post. |
|
| 331 | - if ( null !== $post = $entity_being_edited = get_post() ) { |
|
| 332 | - |
|
| 333 | - $params['post_id'] = $entity_being_edited->ID; |
|
| 334 | - $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 335 | - $params['entityBeingEdited'] = isset( $entity_being_edited->post_type ) && $entity_service->is_entity( $post->ID ) && is_numeric( get_the_ID() ); |
|
| 336 | - // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it |
|
| 337 | - // from the results, since we don't want the current entity to be discovered by the analysis. |
|
| 338 | - // |
|
| 339 | - // See https://github.com/insideout10/wordlift-plugin/issues/345 |
|
| 340 | - $params['itemId'] = $entity_service->get_uri( $entity_being_edited->ID ); |
|
| 341 | - $params['wl_schemaorg_property_nonce'] = wp_create_nonce( 'wl_schemaorg_property' ); |
|
| 342 | - |
|
| 343 | - /* |
|
| 280 | + $autocomplete_scope = $can_edit_wordlift_entities ? WL_AUTOCOMPLETE_SCOPE : "local"; |
|
| 281 | + |
|
| 282 | + // Set the basic params. |
|
| 283 | + $params = array( |
|
| 284 | + // @todo scripts in admin should use wp.post. |
|
| 285 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 286 | + // @todo remove specific actions from settings. |
|
| 287 | + 'action' => 'entity_by_title', |
|
| 288 | + 'datasetUri' => $this->configuration_service->get_dataset_uri(), |
|
| 289 | + 'language' => $this->configuration_service->get_language_code(), |
|
| 290 | + 'link_by_default' => $this->configuration_service->is_link_by_default(), |
|
| 291 | + // Whether the current user is allowed to create new entities. |
|
| 292 | + // |
|
| 293 | + // @see https://github.com/insideout10/wordlift-plugin/issues/561 |
|
| 294 | + 'can_create_entities' => $can_edit_wordlift_entities ? 'yes' : 'no', |
|
| 295 | + 'l10n' => array( |
|
| 296 | + 'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ), |
|
| 297 | + 'logo_selection_title' => __( 'WordLift Choose Logo', 'wordlift' ), |
|
| 298 | + 'logo_selection_button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ), |
|
| 299 | + 'Type at least 3 characters to search...' => _x( 'Type at least 3 characters to search...', 'Autocomplete Select', 'wordlift' ), |
|
| 300 | + 'No results found for your search.' => _x( 'No results found: try changing or removing some words.', 'Autocomplete Select', 'wordlift' ), |
|
| 301 | + 'Please wait while we look for entities in the linked data cloud...' => _x( 'Please wait while we look for entities in the linked data cloud...', 'Autocomplete Select', 'wordlift' ), |
|
| 302 | + 'Add keywords to track' => __( 'Add Keywords to track', 'wordlift' ), |
|
| 303 | + ), |
|
| 304 | + 'wl_autocomplete_nonce' => wp_create_nonce( 'wl_autocomplete' ), |
|
| 305 | + 'autocomplete_scope' => $autocomplete_scope, |
|
| 306 | + /** |
|
| 307 | + * Allow 3rd parties to define the default editor id. This turns useful if 3rd parties load |
|
| 308 | + * or change the TinyMCE id. |
|
| 309 | + * |
|
| 310 | + * The editor id is currently referenced by `src/coffee/editpost-widget/app.services.EditorAdapter.coffee`. |
|
| 311 | + * |
|
| 312 | + * @param string $editor The default editor id, by default `content`. |
|
| 313 | + * |
|
| 314 | + * @see https://github.com/insideout10/wordlift-plugin/issues/848 |
|
| 315 | + * |
|
| 316 | + * @since 3.19.4 |
|
| 317 | + * |
|
| 318 | + */ |
|
| 319 | + 'default_editor_id' => apply_filters( 'wl_default_editor_id', 'content' ), |
|
| 320 | + /** |
|
| 321 | + * Add the link to the Search Keywords admin page. |
|
| 322 | + * |
|
| 323 | + * @since 3.20.0 |
|
| 324 | + */ |
|
| 325 | + 'search_keywords_admin_page' => admin_url( 'admin.php?page=wl_configuration_admin_menu&tab=search-keywords' ), |
|
| 326 | + |
|
| 327 | + 'analysis' => array( '_wpnonce' => wp_create_nonce( 'wl_analyze' ), ) |
|
| 328 | + ); |
|
| 329 | + |
|
| 330 | + // Set post-related values if there's a current post. |
|
| 331 | + if ( null !== $post = $entity_being_edited = get_post() ) { |
|
| 332 | + |
|
| 333 | + $params['post_id'] = $entity_being_edited->ID; |
|
| 334 | + $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 335 | + $params['entityBeingEdited'] = isset( $entity_being_edited->post_type ) && $entity_service->is_entity( $post->ID ) && is_numeric( get_the_ID() ); |
|
| 336 | + // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it |
|
| 337 | + // from the results, since we don't want the current entity to be discovered by the analysis. |
|
| 338 | + // |
|
| 339 | + // See https://github.com/insideout10/wordlift-plugin/issues/345 |
|
| 340 | + $params['itemId'] = $entity_service->get_uri( $entity_being_edited->ID ); |
|
| 341 | + $params['wl_schemaorg_property_nonce'] = wp_create_nonce( 'wl_schemaorg_property' ); |
|
| 342 | + |
|
| 343 | + /* |
|
| 344 | 344 | * Add the `properties` if `WL_ALL_ENTITY_TYPES` is enabled. |
| 345 | 345 | * |
| 346 | 346 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 347 | 347 | */ |
| 348 | - if ( WL_ALL_ENTITY_TYPES ) { |
|
| 349 | - $params['properties'] = Wordlift_Schemaorg_Property_Service::get_instance()->get_all( $post->ID ); |
|
| 350 | - } |
|
| 348 | + if ( WL_ALL_ENTITY_TYPES ) { |
|
| 349 | + $params['properties'] = Wordlift_Schemaorg_Property_Service::get_instance()->get_all( $post->ID ); |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | - } |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - // Finally output the params as `wlSettings` for JavaScript code. |
|
| 355 | - wp_localize_script( $this->plugin_name, 'wlSettings', apply_filters( 'wl_admin_settings', $params ) ); |
|
| 354 | + // Finally output the params as `wlSettings` for JavaScript code. |
|
| 355 | + wp_localize_script( $this->plugin_name, 'wlSettings', apply_filters( 'wl_admin_settings', $params ) ); |
|
| 356 | 356 | |
| 357 | - } |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - /** |
|
| 360 | - * Require files needed for the Admin UI. |
|
| 361 | - * |
|
| 362 | - * @since 3.20.0 |
|
| 363 | - */ |
|
| 364 | - private static function require_files() { |
|
| 359 | + /** |
|
| 360 | + * Require files needed for the Admin UI. |
|
| 361 | + * |
|
| 362 | + * @since 3.20.0 |
|
| 363 | + */ |
|
| 364 | + private static function require_files() { |
|
| 365 | 365 | |
| 366 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard-latest-news.php'; |
|
| 367 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-service.php'; |
|
| 368 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-ajax-adapter.php'; |
|
| 369 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard-v2.php'; |
|
| 370 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-not-enriched-filter.php'; |
|
| 366 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard-latest-news.php'; |
|
| 367 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-service.php'; |
|
| 368 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-ajax-adapter.php'; |
|
| 369 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard-v2.php'; |
|
| 370 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-not-enriched-filter.php'; |
|
| 371 | 371 | |
| 372 | - } |
|
| 372 | + } |
|
| 373 | 373 | |
| 374 | - /** |
|
| 375 | - * Add Wordlift custom block category. |
|
| 376 | - * |
|
| 377 | - * @since 3.21.0 |
|
| 378 | - * @since 3.24.2 this function isn't called anymore as it was causing the WordLift block category to multiply |
|
| 379 | - * in Block Editor, https://github.com/insideout10/wordlift-plugin/issues/1004 |
|
| 380 | - */ |
|
| 374 | + /** |
|
| 375 | + * Add Wordlift custom block category. |
|
| 376 | + * |
|
| 377 | + * @since 3.21.0 |
|
| 378 | + * @since 3.24.2 this function isn't called anymore as it was causing the WordLift block category to multiply |
|
| 379 | + * in Block Editor, https://github.com/insideout10/wordlift-plugin/issues/1004 |
|
| 380 | + */ |
|
| 381 | 381 | |
| 382 | 382 | // private static function add_block_category() { |
| 383 | 383 | // add_filter( 'block_categories', function ( $categories, $post ) { |
@@ -394,22 +394,22 @@ discard block |
||
| 394 | 394 | // }, 10, 2 ); |
| 395 | 395 | // } |
| 396 | 396 | |
| 397 | - public static function is_gutenberg() { |
|
| 398 | - if ( function_exists( 'is_gutenberg_page' ) && |
|
| 399 | - is_gutenberg_page() |
|
| 400 | - ) { |
|
| 401 | - // The Gutenberg plugin is on. |
|
| 402 | - return true; |
|
| 403 | - } |
|
| 404 | - $current_screen = get_current_screen(); |
|
| 405 | - if ( method_exists( $current_screen, 'is_block_editor' ) && |
|
| 406 | - $current_screen->is_block_editor() |
|
| 407 | - ) { |
|
| 408 | - // Gutenberg page on 5+. |
|
| 409 | - return true; |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - return false; |
|
| 413 | - } |
|
| 397 | + public static function is_gutenberg() { |
|
| 398 | + if ( function_exists( 'is_gutenberg_page' ) && |
|
| 399 | + is_gutenberg_page() |
|
| 400 | + ) { |
|
| 401 | + // The Gutenberg plugin is on. |
|
| 402 | + return true; |
|
| 403 | + } |
|
| 404 | + $current_screen = get_current_screen(); |
|
| 405 | + if ( method_exists( $current_screen, 'is_block_editor' ) && |
|
| 406 | + $current_screen->is_block_editor() |
|
| 407 | + ) { |
|
| 408 | + // Gutenberg page on 5+. |
|
| 409 | + return true; |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + return false; |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | 415 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @since 1.0.0 |
| 95 | 95 | * |
| 96 | 96 | */ |
| 97 | - public function __construct( $plugin_name, $version, $configuration_service, $notice_service, $user_service ) { |
|
| 97 | + public function __construct($plugin_name, $version, $configuration_service, $notice_service, $user_service) { |
|
| 98 | 98 | |
| 99 | 99 | $this->plugin_name = $plugin_name; |
| 100 | 100 | $this->version = $version; |
@@ -105,18 +105,18 @@ discard block |
||
| 105 | 105 | $dataset_uri = $configuration_service->get_dataset_uri(); |
| 106 | 106 | $key = $configuration_service->get_key(); |
| 107 | 107 | |
| 108 | - if ( empty( $dataset_uri ) ) { |
|
| 108 | + if (empty($dataset_uri)) { |
|
| 109 | 109 | $settings_page = Wordlift_Admin_Settings_Page::get_instance(); |
| 110 | - if ( empty( $key ) ) { |
|
| 111 | - $error = sprintf( esc_html__( "WordLift's key isn't set, please open the %s to set WordLift's key.", 'wordlift' ), '<a href="' . $settings_page->get_url() . '">' . esc_html__( 'settings page', 'wordlift' ) . '</a>' ); |
|
| 110 | + if (empty($key)) { |
|
| 111 | + $error = sprintf(esc_html__("WordLift's key isn't set, please open the %s to set WordLift's key.", 'wordlift'), '<a href="'.$settings_page->get_url().'">'.esc_html__('settings page', 'wordlift').'</a>'); |
|
| 112 | 112 | } else { |
| 113 | - $error = sprintf( esc_html__( "WordLift's dataset URI is not configured: please open the %s to set WordLift's key again.", 'wordlift' ), '<a href="' . $settings_page->get_url() . '">' . esc_html__( 'settings page', 'wordlift' ) . '</a>' ); |
|
| 113 | + $error = sprintf(esc_html__("WordLift's dataset URI is not configured: please open the %s to set WordLift's key again.", 'wordlift'), '<a href="'.$settings_page->get_url().'">'.esc_html__('settings page', 'wordlift').'</a>'); |
|
| 114 | 114 | } |
| 115 | - $notice_service->add_error( $error ); |
|
| 115 | + $notice_service->add_error($error); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // Load additional code if we're in the admin UI. |
| 119 | - if ( is_admin() ) { |
|
| 119 | + if (is_admin()) { |
|
| 120 | 120 | |
| 121 | 121 | // Require the PHP files for the next code fragment. |
| 122 | 122 | self::require_files(); |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | new Wordlift_Dashboard_Latest_News(); |
| 134 | 134 | |
| 135 | 135 | // Search Rankings. |
| 136 | - $search_rankings_service = new Wordlift_Admin_Search_Rankings_Service( Wordlift_Api_Service::get_instance() ); |
|
| 137 | - new Wordlift_Admin_Search_Rankings_Ajax_Adapter( $search_rankings_service ); |
|
| 136 | + $search_rankings_service = new Wordlift_Admin_Search_Rankings_Service(Wordlift_Api_Service::get_instance()); |
|
| 137 | + new Wordlift_Admin_Search_Rankings_Ajax_Adapter($search_rankings_service); |
|
| 138 | 138 | |
| 139 | 139 | /* |
| 140 | 140 | * Add support for `All Entity Types`. |
@@ -143,15 +143,15 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 145 | 145 | */ |
| 146 | - if ( WL_ALL_ENTITY_TYPES ) { |
|
| 147 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-schemaorg-taxonomy-metabox.php'; |
|
| 148 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-schemaorg-property-metabox.php'; |
|
| 146 | + if (WL_ALL_ENTITY_TYPES) { |
|
| 147 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-schemaorg-taxonomy-metabox.php'; |
|
| 148 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-schemaorg-property-metabox.php'; |
|
| 149 | 149 | |
| 150 | 150 | // new Wordlift_Admin_Schemaorg_Property_Metabox( Wordlift_Schemaorg_Property_Service::get_instance() ); |
| 151 | 151 | /* |
| 152 | 152 | * The `Mappings` admin page. |
| 153 | 153 | */ |
| 154 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-mappings-page.php'; |
|
| 154 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-mappings-page.php'; |
|
| 155 | 155 | new Wordlift_Admin_Mappings_Page(); |
| 156 | 156 | |
| 157 | 157 | /* |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | * |
| 160 | 160 | * @since 3.20.0 |
| 161 | 161 | */ |
| 162 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/schemaorg/class-wordlift-schemaorg-sync-batch-operation.php'; |
|
| 162 | + require_once plugin_dir_path(dirname(__FILE__)).'includes/schemaorg/class-wordlift-schemaorg-sync-batch-operation.php'; |
|
| 163 | 163 | |
| 164 | - $this->sync_batch_operation_ajax_adapter = new Wordlift_Batch_Operation_Ajax_Adapter( new Wordlift_Schemaorg_Sync_Batch_Operation(), 'wl_schemaorg_sync' ); |
|
| 164 | + $this->sync_batch_operation_ajax_adapter = new Wordlift_Batch_Operation_Ajax_Adapter(new Wordlift_Schemaorg_Sync_Batch_Operation(), 'wl_schemaorg_sync'); |
|
| 165 | 165 | |
| 166 | 166 | } |
| 167 | 167 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @since 3.20.0 |
| 172 | 172 | */ |
| 173 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-term-adapter.php'; |
|
| 173 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-term-adapter.php'; |
|
| 174 | 174 | new Wordlift_Admin_Term_Adapter(); |
| 175 | 175 | |
| 176 | 176 | /* |
@@ -197,10 +197,10 @@ discard block |
||
| 197 | 197 | new Mappings_REST_Controller(); |
| 198 | 198 | |
| 199 | 199 | // Only enable the Mappings UI if the constant is defined. |
| 200 | - if ( defined( 'WL_ENABLE_MAPPINGS' ) && WL_ENABLE_MAPPINGS ) { |
|
| 200 | + if (defined('WL_ENABLE_MAPPINGS') && WL_ENABLE_MAPPINGS) { |
|
| 201 | 201 | // Add Mappings and Edit Mappings page. |
| 202 | 202 | new Admin_Mappings_Page(); |
| 203 | - new Edit_Mappings_Page( new Mappings_Transform_Functions_Registry() ); |
|
| 203 | + new Edit_Mappings_Page(new Mappings_Transform_Functions_Registry()); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // Set the singleton instance. |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * class. |
| 240 | 240 | */ |
| 241 | 241 | |
| 242 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-admin.css', array(), $this->version, 'all' ); |
|
| 242 | + wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/wordlift-admin.css', array(), $this->version, 'all'); |
|
| 243 | 243 | |
| 244 | 244 | } |
| 245 | 245 | |
@@ -257,19 +257,19 @@ discard block |
||
| 257 | 257 | * @since 3.20.0 |
| 258 | 258 | */ |
| 259 | 259 | $screen = get_current_screen(); |
| 260 | - if ( is_a( $screen, 'WP_Screen' ) && 'filter-urls_page_filter_urls_form' === $screen->id ) { |
|
| 260 | + if (is_a($screen, 'WP_Screen') && 'filter-urls_page_filter_urls_form' === $screen->id) { |
|
| 261 | 261 | return; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | // Enqueue the admin scripts. |
| 265 | - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/1/admin.js', array( |
|
| 265 | + wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/1/admin.js', array( |
|
| 266 | 266 | 'jquery', |
| 267 | 267 | 'underscore', |
| 268 | 268 | 'backbone', |
| 269 | - ), $this->version, false ); |
|
| 269 | + ), $this->version, false); |
|
| 270 | 270 | |
| 271 | 271 | |
| 272 | - $can_edit_wordlift_entities = current_user_can( 'edit_wordlift_entities' ); |
|
| 272 | + $can_edit_wordlift_entities = current_user_can('edit_wordlift_entities'); |
|
| 273 | 273 | |
| 274 | 274 | /* |
| 275 | 275 | * People that can create entities will see the scope set in the wp-config.php file (by default `cloud`). People |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | // Set the basic params. |
| 283 | 283 | $params = array( |
| 284 | 284 | // @todo scripts in admin should use wp.post. |
| 285 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 285 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 286 | 286 | // @todo remove specific actions from settings. |
| 287 | 287 | 'action' => 'entity_by_title', |
| 288 | 288 | 'datasetUri' => $this->configuration_service->get_dataset_uri(), |
@@ -293,15 +293,15 @@ discard block |
||
| 293 | 293 | // @see https://github.com/insideout10/wordlift-plugin/issues/561 |
| 294 | 294 | 'can_create_entities' => $can_edit_wordlift_entities ? 'yes' : 'no', |
| 295 | 295 | 'l10n' => array( |
| 296 | - 'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ), |
|
| 297 | - 'logo_selection_title' => __( 'WordLift Choose Logo', 'wordlift' ), |
|
| 298 | - 'logo_selection_button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ), |
|
| 299 | - 'Type at least 3 characters to search...' => _x( 'Type at least 3 characters to search...', 'Autocomplete Select', 'wordlift' ), |
|
| 300 | - 'No results found for your search.' => _x( 'No results found: try changing or removing some words.', 'Autocomplete Select', 'wordlift' ), |
|
| 301 | - 'Please wait while we look for entities in the linked data cloud...' => _x( 'Please wait while we look for entities in the linked data cloud...', 'Autocomplete Select', 'wordlift' ), |
|
| 302 | - 'Add keywords to track' => __( 'Add Keywords to track', 'wordlift' ), |
|
| 296 | + 'You already published an entity with the same name' => __('You already published an entity with the same name: ', 'wordlift'), |
|
| 297 | + 'logo_selection_title' => __('WordLift Choose Logo', 'wordlift'), |
|
| 298 | + 'logo_selection_button' => array('text' => __('Choose Logo', 'wordlift')), |
|
| 299 | + 'Type at least 3 characters to search...' => _x('Type at least 3 characters to search...', 'Autocomplete Select', 'wordlift'), |
|
| 300 | + 'No results found for your search.' => _x('No results found: try changing or removing some words.', 'Autocomplete Select', 'wordlift'), |
|
| 301 | + 'Please wait while we look for entities in the linked data cloud...' => _x('Please wait while we look for entities in the linked data cloud...', 'Autocomplete Select', 'wordlift'), |
|
| 302 | + 'Add keywords to track' => __('Add Keywords to track', 'wordlift'), |
|
| 303 | 303 | ), |
| 304 | - 'wl_autocomplete_nonce' => wp_create_nonce( 'wl_autocomplete' ), |
|
| 304 | + 'wl_autocomplete_nonce' => wp_create_nonce('wl_autocomplete'), |
|
| 305 | 305 | 'autocomplete_scope' => $autocomplete_scope, |
| 306 | 306 | /** |
| 307 | 307 | * Allow 3rd parties to define the default editor id. This turns useful if 3rd parties load |
@@ -316,43 +316,43 @@ discard block |
||
| 316 | 316 | * @since 3.19.4 |
| 317 | 317 | * |
| 318 | 318 | */ |
| 319 | - 'default_editor_id' => apply_filters( 'wl_default_editor_id', 'content' ), |
|
| 319 | + 'default_editor_id' => apply_filters('wl_default_editor_id', 'content'), |
|
| 320 | 320 | /** |
| 321 | 321 | * Add the link to the Search Keywords admin page. |
| 322 | 322 | * |
| 323 | 323 | * @since 3.20.0 |
| 324 | 324 | */ |
| 325 | - 'search_keywords_admin_page' => admin_url( 'admin.php?page=wl_configuration_admin_menu&tab=search-keywords' ), |
|
| 325 | + 'search_keywords_admin_page' => admin_url('admin.php?page=wl_configuration_admin_menu&tab=search-keywords'), |
|
| 326 | 326 | |
| 327 | - 'analysis' => array( '_wpnonce' => wp_create_nonce( 'wl_analyze' ), ) |
|
| 327 | + 'analysis' => array('_wpnonce' => wp_create_nonce('wl_analyze'),) |
|
| 328 | 328 | ); |
| 329 | 329 | |
| 330 | 330 | // Set post-related values if there's a current post. |
| 331 | - if ( null !== $post = $entity_being_edited = get_post() ) { |
|
| 331 | + if (null !== $post = $entity_being_edited = get_post()) { |
|
| 332 | 332 | |
| 333 | 333 | $params['post_id'] = $entity_being_edited->ID; |
| 334 | 334 | $entity_service = Wordlift_Entity_Service::get_instance(); |
| 335 | - $params['entityBeingEdited'] = isset( $entity_being_edited->post_type ) && $entity_service->is_entity( $post->ID ) && is_numeric( get_the_ID() ); |
|
| 335 | + $params['entityBeingEdited'] = isset($entity_being_edited->post_type) && $entity_service->is_entity($post->ID) && is_numeric(get_the_ID()); |
|
| 336 | 336 | // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it |
| 337 | 337 | // from the results, since we don't want the current entity to be discovered by the analysis. |
| 338 | 338 | // |
| 339 | 339 | // See https://github.com/insideout10/wordlift-plugin/issues/345 |
| 340 | - $params['itemId'] = $entity_service->get_uri( $entity_being_edited->ID ); |
|
| 341 | - $params['wl_schemaorg_property_nonce'] = wp_create_nonce( 'wl_schemaorg_property' ); |
|
| 340 | + $params['itemId'] = $entity_service->get_uri($entity_being_edited->ID); |
|
| 341 | + $params['wl_schemaorg_property_nonce'] = wp_create_nonce('wl_schemaorg_property'); |
|
| 342 | 342 | |
| 343 | 343 | /* |
| 344 | 344 | * Add the `properties` if `WL_ALL_ENTITY_TYPES` is enabled. |
| 345 | 345 | * |
| 346 | 346 | * @see https://github.com/insideout10/wordlift-plugin/issues/835 |
| 347 | 347 | */ |
| 348 | - if ( WL_ALL_ENTITY_TYPES ) { |
|
| 349 | - $params['properties'] = Wordlift_Schemaorg_Property_Service::get_instance()->get_all( $post->ID ); |
|
| 348 | + if (WL_ALL_ENTITY_TYPES) { |
|
| 349 | + $params['properties'] = Wordlift_Schemaorg_Property_Service::get_instance()->get_all($post->ID); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | // Finally output the params as `wlSettings` for JavaScript code. |
| 355 | - wp_localize_script( $this->plugin_name, 'wlSettings', apply_filters( 'wl_admin_settings', $params ) ); |
|
| 355 | + wp_localize_script($this->plugin_name, 'wlSettings', apply_filters('wl_admin_settings', $params)); |
|
| 356 | 356 | |
| 357 | 357 | } |
| 358 | 358 | |
@@ -363,11 +363,11 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | private static function require_files() { |
| 365 | 365 | |
| 366 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard-latest-news.php'; |
|
| 367 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-service.php'; |
|
| 368 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-search-rankings-ajax-adapter.php'; |
|
| 369 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard-v2.php'; |
|
| 370 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-not-enriched-filter.php'; |
|
| 366 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard-latest-news.php'; |
|
| 367 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-search-rankings-service.php'; |
|
| 368 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-search-rankings-ajax-adapter.php'; |
|
| 369 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard-v2.php'; |
|
| 370 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-not-enriched-filter.php'; |
|
| 371 | 371 | |
| 372 | 372 | } |
| 373 | 373 | |
@@ -395,14 +395,14 @@ discard block |
||
| 395 | 395 | // } |
| 396 | 396 | |
| 397 | 397 | public static function is_gutenberg() { |
| 398 | - if ( function_exists( 'is_gutenberg_page' ) && |
|
| 398 | + if (function_exists('is_gutenberg_page') && |
|
| 399 | 399 | is_gutenberg_page() |
| 400 | 400 | ) { |
| 401 | 401 | // The Gutenberg plugin is on. |
| 402 | 402 | return true; |
| 403 | 403 | } |
| 404 | 404 | $current_screen = get_current_screen(); |
| 405 | - if ( method_exists( $current_screen, 'is_block_editor' ) && |
|
| 405 | + if (method_exists($current_screen, 'is_block_editor') && |
|
| 406 | 406 | $current_screen->is_block_editor() |
| 407 | 407 | ) { |
| 408 | 408 | // Gutenberg page on 5+. |