@@ -22,119 +22,119 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class Wordlift_Admin { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * The ID of this plugin. |
|
| 27 | - * |
|
| 28 | - * @since 1.0.0 |
|
| 29 | - * @access private |
|
| 30 | - * @var string $plugin_name The ID of this plugin. |
|
| 31 | - */ |
|
| 32 | - private $plugin_name; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * The version of this plugin. |
|
| 36 | - * |
|
| 37 | - * @since 1.0.0 |
|
| 38 | - * @access private |
|
| 39 | - * @var string $version The current version of this plugin. |
|
| 40 | - */ |
|
| 41 | - private $version; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Initialize the class and set its properties. |
|
| 45 | - * |
|
| 46 | - * @since 1.0.0 |
|
| 47 | - * |
|
| 48 | - * @param string $plugin_name The name of this plugin. |
|
| 49 | - * @param string $version The version of this plugin. |
|
| 50 | - */ |
|
| 51 | - public function __construct( $plugin_name, $version ) { |
|
| 52 | - |
|
| 53 | - $this->plugin_name = $plugin_name; |
|
| 54 | - $this->version = $version; |
|
| 55 | - |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Register the stylesheets for the admin area. |
|
| 60 | - * |
|
| 61 | - * @since 1.0.0 |
|
| 62 | - */ |
|
| 63 | - public function enqueue_styles() { |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * This function is provided for demonstration purposes only. |
|
| 67 | - * |
|
| 68 | - * An instance of this class should be passed to the run() function |
|
| 69 | - * defined in Wordlift_Loader as all of the hooks are defined |
|
| 70 | - * in that particular class. |
|
| 71 | - * |
|
| 72 | - * The Wordlift_Loader will then create the relationship |
|
| 73 | - * between the defined hooks and the functions defined in this |
|
| 74 | - * class. |
|
| 75 | - */ |
|
| 76 | - |
|
| 77 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-admin.css', array(), $this->version, 'all' ); |
|
| 78 | - |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * Register the JavaScript for the admin area. |
|
| 83 | - * |
|
| 84 | - * @since 1.0.0 |
|
| 85 | - */ |
|
| 86 | - public function enqueue_scripts() { |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * This function is provided for demonstration purposes only. |
|
| 90 | - * |
|
| 91 | - * An instance of this class should be passed to the run() function |
|
| 92 | - * defined in Wordlift_Loader as all of the hooks are defined |
|
| 93 | - * in that particular class. |
|
| 94 | - * |
|
| 95 | - * The Wordlift_Loader will then create the relationship |
|
| 96 | - * between the defined hooks and the functions defined in this |
|
| 97 | - * class. |
|
| 98 | - */ |
|
| 99 | - |
|
| 100 | - // Get the current screen. |
|
| 101 | - $screen = get_current_screen(); |
|
| 102 | - |
|
| 103 | - // If there's no screen or we're not in edit mode, don't provide the `wlSettings`, |
|
| 104 | - // since the current admin script only provides the configuration data for |
|
| 105 | - // the title check. |
|
| 106 | - // |
|
| 107 | - // This might change as soon as we structure the JavaScript code into well |
|
| 108 | - // defined script files. |
|
| 109 | - if ( null === $screen || 'edit' !== $screen->parent_base ) { |
|
| 110 | - return; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - // Enqueue our script. |
|
| 114 | - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-admin.bundle.js', array( 'jquery' ), $this->version, false ); |
|
| 115 | - |
|
| 116 | - // Add WL api endpoint to retrieve entities based on their title. We only load it on the entity edit page. |
|
| 117 | - $entity_being_edited = get_post(); |
|
| 118 | - |
|
| 119 | - wp_localize_script( $this->plugin_name, 'wlSettings', array( |
|
| 120 | - // @todo scripts in admin should use wp.post. |
|
| 121 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 122 | - // @todo remove specific actions from settings. |
|
| 123 | - 'action' => 'entity_by_title', |
|
| 124 | - 'post_id' => $entity_being_edited->ID, |
|
| 125 | - 'entityBeingEdited' => isset( $entity_being_edited->post_type ) && $entity_being_edited->post_type == Wordlift_Entity_Service::TYPE_NAME && is_numeric( get_the_ID() ), |
|
| 126 | - 'language' => Wordlift_Configuration_Service::get_instance()->get_language_code(), |
|
| 127 | - // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it |
|
| 128 | - // from the results, since we don't want the current entity to be discovered by the analysis. |
|
| 129 | - // |
|
| 130 | - // See https://github.com/insideout10/wordlift-plugin/issues/345 |
|
| 131 | - 'itemId' => Wordlift_Entity_Service::get_instance()->get_uri( $entity_being_edited->ID ), |
|
| 132 | - 'l10n' => array( |
|
| 133 | - 'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ), |
|
| 134 | - ), |
|
| 135 | - ) |
|
| 136 | - ); |
|
| 137 | - |
|
| 138 | - } |
|
| 25 | + /** |
|
| 26 | + * The ID of this plugin. |
|
| 27 | + * |
|
| 28 | + * @since 1.0.0 |
|
| 29 | + * @access private |
|
| 30 | + * @var string $plugin_name The ID of this plugin. |
|
| 31 | + */ |
|
| 32 | + private $plugin_name; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * The version of this plugin. |
|
| 36 | + * |
|
| 37 | + * @since 1.0.0 |
|
| 38 | + * @access private |
|
| 39 | + * @var string $version The current version of this plugin. |
|
| 40 | + */ |
|
| 41 | + private $version; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Initialize the class and set its properties. |
|
| 45 | + * |
|
| 46 | + * @since 1.0.0 |
|
| 47 | + * |
|
| 48 | + * @param string $plugin_name The name of this plugin. |
|
| 49 | + * @param string $version The version of this plugin. |
|
| 50 | + */ |
|
| 51 | + public function __construct( $plugin_name, $version ) { |
|
| 52 | + |
|
| 53 | + $this->plugin_name = $plugin_name; |
|
| 54 | + $this->version = $version; |
|
| 55 | + |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Register the stylesheets for the admin area. |
|
| 60 | + * |
|
| 61 | + * @since 1.0.0 |
|
| 62 | + */ |
|
| 63 | + public function enqueue_styles() { |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * This function is provided for demonstration purposes only. |
|
| 67 | + * |
|
| 68 | + * An instance of this class should be passed to the run() function |
|
| 69 | + * defined in Wordlift_Loader as all of the hooks are defined |
|
| 70 | + * in that particular class. |
|
| 71 | + * |
|
| 72 | + * The Wordlift_Loader will then create the relationship |
|
| 73 | + * between the defined hooks and the functions defined in this |
|
| 74 | + * class. |
|
| 75 | + */ |
|
| 76 | + |
|
| 77 | + wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-admin.css', array(), $this->version, 'all' ); |
|
| 78 | + |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * Register the JavaScript for the admin area. |
|
| 83 | + * |
|
| 84 | + * @since 1.0.0 |
|
| 85 | + */ |
|
| 86 | + public function enqueue_scripts() { |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * This function is provided for demonstration purposes only. |
|
| 90 | + * |
|
| 91 | + * An instance of this class should be passed to the run() function |
|
| 92 | + * defined in Wordlift_Loader as all of the hooks are defined |
|
| 93 | + * in that particular class. |
|
| 94 | + * |
|
| 95 | + * The Wordlift_Loader will then create the relationship |
|
| 96 | + * between the defined hooks and the functions defined in this |
|
| 97 | + * class. |
|
| 98 | + */ |
|
| 99 | + |
|
| 100 | + // Get the current screen. |
|
| 101 | + $screen = get_current_screen(); |
|
| 102 | + |
|
| 103 | + // If there's no screen or we're not in edit mode, don't provide the `wlSettings`, |
|
| 104 | + // since the current admin script only provides the configuration data for |
|
| 105 | + // the title check. |
|
| 106 | + // |
|
| 107 | + // This might change as soon as we structure the JavaScript code into well |
|
| 108 | + // defined script files. |
|
| 109 | + if ( null === $screen || 'edit' !== $screen->parent_base ) { |
|
| 110 | + return; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + // Enqueue our script. |
|
| 114 | + wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-admin.bundle.js', array( 'jquery' ), $this->version, false ); |
|
| 115 | + |
|
| 116 | + // Add WL api endpoint to retrieve entities based on their title. We only load it on the entity edit page. |
|
| 117 | + $entity_being_edited = get_post(); |
|
| 118 | + |
|
| 119 | + wp_localize_script( $this->plugin_name, 'wlSettings', array( |
|
| 120 | + // @todo scripts in admin should use wp.post. |
|
| 121 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 122 | + // @todo remove specific actions from settings. |
|
| 123 | + 'action' => 'entity_by_title', |
|
| 124 | + 'post_id' => $entity_being_edited->ID, |
|
| 125 | + 'entityBeingEdited' => isset( $entity_being_edited->post_type ) && $entity_being_edited->post_type == Wordlift_Entity_Service::TYPE_NAME && is_numeric( get_the_ID() ), |
|
| 126 | + 'language' => Wordlift_Configuration_Service::get_instance()->get_language_code(), |
|
| 127 | + // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it |
|
| 128 | + // from the results, since we don't want the current entity to be discovered by the analysis. |
|
| 129 | + // |
|
| 130 | + // See https://github.com/insideout10/wordlift-plugin/issues/345 |
|
| 131 | + 'itemId' => Wordlift_Entity_Service::get_instance()->get_uri( $entity_being_edited->ID ), |
|
| 132 | + 'l10n' => array( |
|
| 133 | + 'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ), |
|
| 134 | + ), |
|
| 135 | + ) |
|
| 136 | + ); |
|
| 137 | + |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param string $plugin_name The name of this plugin. |
| 49 | 49 | * @param string $version The version of this plugin. |
| 50 | 50 | */ |
| 51 | - public function __construct( $plugin_name, $version ) { |
|
| 51 | + public function __construct($plugin_name, $version) { |
|
| 52 | 52 | |
| 53 | 53 | $this->plugin_name = $plugin_name; |
| 54 | 54 | $this->version = $version; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * class. |
| 75 | 75 | */ |
| 76 | 76 | |
| 77 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-admin.css', array(), $this->version, 'all' ); |
|
| 77 | + wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/wordlift-admin.css', array(), $this->version, 'all'); |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
@@ -106,31 +106,31 @@ discard block |
||
| 106 | 106 | // |
| 107 | 107 | // This might change as soon as we structure the JavaScript code into well |
| 108 | 108 | // defined script files. |
| 109 | - if ( null === $screen || 'edit' !== $screen->parent_base ) { |
|
| 109 | + if (null === $screen || 'edit' !== $screen->parent_base) { |
|
| 110 | 110 | return; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // Enqueue our script. |
| 114 | - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-admin.bundle.js', array( 'jquery' ), $this->version, false ); |
|
| 114 | + wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/wordlift-admin.bundle.js', array('jquery'), $this->version, false); |
|
| 115 | 115 | |
| 116 | 116 | // Add WL api endpoint to retrieve entities based on their title. We only load it on the entity edit page. |
| 117 | 117 | $entity_being_edited = get_post(); |
| 118 | 118 | |
| 119 | - wp_localize_script( $this->plugin_name, 'wlSettings', array( |
|
| 119 | + wp_localize_script($this->plugin_name, 'wlSettings', array( |
|
| 120 | 120 | // @todo scripts in admin should use wp.post. |
| 121 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 121 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 122 | 122 | // @todo remove specific actions from settings. |
| 123 | 123 | 'action' => 'entity_by_title', |
| 124 | 124 | 'post_id' => $entity_being_edited->ID, |
| 125 | - 'entityBeingEdited' => isset( $entity_being_edited->post_type ) && $entity_being_edited->post_type == Wordlift_Entity_Service::TYPE_NAME && is_numeric( get_the_ID() ), |
|
| 125 | + 'entityBeingEdited' => isset($entity_being_edited->post_type) && $entity_being_edited->post_type == Wordlift_Entity_Service::TYPE_NAME && is_numeric(get_the_ID()), |
|
| 126 | 126 | 'language' => Wordlift_Configuration_Service::get_instance()->get_language_code(), |
| 127 | 127 | // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it |
| 128 | 128 | // from the results, since we don't want the current entity to be discovered by the analysis. |
| 129 | 129 | // |
| 130 | 130 | // See https://github.com/insideout10/wordlift-plugin/issues/345 |
| 131 | - 'itemId' => Wordlift_Entity_Service::get_instance()->get_uri( $entity_being_edited->ID ), |
|
| 131 | + 'itemId' => Wordlift_Entity_Service::get_instance()->get_uri($entity_being_edited->ID), |
|
| 132 | 132 | 'l10n' => array( |
| 133 | - 'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ), |
|
| 133 | + 'You already published an entity with the same name' => __('You already published an entity with the same name: ', 'wordlift'), |
|
| 134 | 134 | ), |
| 135 | 135 | ) |
| 136 | 136 | ); |