@@ -22,173 +22,173 @@ |
||
| 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 | - * The {@link Wordlift_Configuration_Service} instance. |
|
| 45 | - * |
|
| 46 | - * @since 3.14.0 |
|
| 47 | - * @access private |
|
| 48 | - * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance. |
|
| 49 | - */ |
|
| 50 | - private $configuration_service; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * The {@link Wordlift_User_Service} instance. |
|
| 54 | - * |
|
| 55 | - * @since 3.14.0 |
|
| 56 | - * @access private |
|
| 57 | - * @var \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
| 58 | - */ |
|
| 59 | - private $user_service; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Initialize the class and set its properties. |
|
| 63 | - * |
|
| 64 | - * @since 1.0.0 |
|
| 65 | - * |
|
| 66 | - * @param string $plugin_name The name of this plugin. |
|
| 67 | - * @param string $version The version of this plugin. |
|
| 68 | - * @param \Wordlift_Configuration_Service $configuration_service The configuration service. |
|
| 69 | - * @param \Wordlift_Notice_Service $notice_service The notice service. |
|
| 70 | - * @param \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
| 71 | - */ |
|
| 72 | - public function __construct( $plugin_name, $version, $configuration_service, $notice_service, $user_service ) { |
|
| 73 | - |
|
| 74 | - $this->plugin_name = $plugin_name; |
|
| 75 | - $this->version = $version; |
|
| 76 | - |
|
| 77 | - $this->configuration_service = $configuration_service; |
|
| 78 | - $this->user_service = $user_service; |
|
| 79 | - |
|
| 80 | - $dataset_uri = $configuration_service->get_dataset_uri(); |
|
| 81 | - $key = $configuration_service->get_key(); |
|
| 82 | - |
|
| 83 | - if ( empty( $dataset_uri ) ) { |
|
| 84 | - $settings_page = Wordlift_Admin_Settings_Page::get_instance(); |
|
| 85 | - if ( empty( $key ) ) { |
|
| 86 | - $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>' ); |
|
| 87 | - } else { |
|
| 88 | - $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>' ); |
|
| 89 | - } |
|
| 90 | - $notice_service->add_error( $error ); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // Load additional code if we're in the admin UI. |
|
| 94 | - if ( is_admin() ) { |
|
| 95 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard-latest-news.php'; |
|
| 96 | - |
|
| 97 | - new Wordlift_Dashboard_Latest_News(); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Register the stylesheets for the admin area. |
|
| 104 | - * |
|
| 105 | - * @since 1.0.0 |
|
| 106 | - */ |
|
| 107 | - public function enqueue_styles() { |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * This function is provided for demonstration purposes only. |
|
| 111 | - * |
|
| 112 | - * An instance of this class should be passed to the run() function |
|
| 113 | - * defined in Wordlift_Loader as all of the hooks are defined |
|
| 114 | - * in that particular class. |
|
| 115 | - * |
|
| 116 | - * The Wordlift_Loader will then create the relationship |
|
| 117 | - * between the defined hooks and the functions defined in this |
|
| 118 | - * class. |
|
| 119 | - */ |
|
| 120 | - |
|
| 121 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-admin.css', array(), $this->version, 'all' ); |
|
| 122 | - |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Register the JavaScript for the admin area. |
|
| 127 | - * |
|
| 128 | - * @since 1.0.0 |
|
| 129 | - */ |
|
| 130 | - public function enqueue_scripts() { |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * This function is provided for demonstration purposes only. |
|
| 134 | - * |
|
| 135 | - * An instance of this class should be passed to the run() function |
|
| 136 | - * defined in Wordlift_Loader as all of the hooks are defined |
|
| 137 | - * in that particular class. |
|
| 138 | - * |
|
| 139 | - * The Wordlift_Loader will then create the relationship |
|
| 140 | - * between the defined hooks and the functions defined in this |
|
| 141 | - * class. |
|
| 142 | - */ |
|
| 143 | - |
|
| 144 | - // Enqueue the admin scripts. |
|
| 145 | - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/1/admin.js', array( |
|
| 146 | - 'jquery', |
|
| 147 | - 'underscore', |
|
| 148 | - 'backbone', |
|
| 149 | - ), $this->version, false ); |
|
| 150 | - |
|
| 151 | - // Set the basic params. |
|
| 152 | - $params = array( |
|
| 153 | - // @todo scripts in admin should use wp.post. |
|
| 154 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 155 | - // @todo remove specific actions from settings. |
|
| 156 | - 'action' => 'entity_by_title', |
|
| 157 | - 'datasetUri' => $this->configuration_service->get_dataset_uri(), |
|
| 158 | - 'language' => $this->configuration_service->get_language_code(), |
|
| 159 | - 'link_by_default' => $this->configuration_service->is_link_by_default(), |
|
| 160 | - // Whether the current user is allowed to create new entities. |
|
| 161 | - // |
|
| 162 | - // @see https://github.com/insideout10/wordlift-plugin/issues/561 |
|
| 163 | - 'can_create_entities' => current_user_can( 'edit_wordlift_entities' ) ? 'yes' : 'no', |
|
| 164 | - 'l10n' => array( |
|
| 165 | - 'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ), |
|
| 166 | - 'logo_selection_title' => __( 'WordLift Choose Logo', 'wordlift' ), |
|
| 167 | - 'logo_selection_button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ), |
|
| 168 | - 'Type at least 3 characters to search...' => _x( 'Type at least 3 characters to search...', 'Autocomplete Select', 'wordlift' ), |
|
| 169 | - 'No results found for your search.' => _x( 'No results found: try changing or removing some words.', 'Autocomplete Select', 'wordlift' ), |
|
| 170 | - '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' ), |
|
| 171 | - ), |
|
| 172 | - 'wl_autocomplete_nonce' => wp_create_nonce( 'wordlift_autocomplete' ), |
|
| 173 | - ); |
|
| 174 | - |
|
| 175 | - // Set post-related values if there's a current post. |
|
| 176 | - if ( null !== $post = $entity_being_edited = get_post() ) { |
|
| 177 | - |
|
| 178 | - $params['post_id'] = $entity_being_edited->ID; |
|
| 179 | - $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 180 | - $params['entityBeingEdited'] = isset( $entity_being_edited->post_type ) && $entity_service->is_entity( $post->ID ) && is_numeric( get_the_ID() ); |
|
| 181 | - // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it |
|
| 182 | - // from the results, since we don't want the current entity to be discovered by the analysis. |
|
| 183 | - // |
|
| 184 | - // See https://github.com/insideout10/wordlift-plugin/issues/345 |
|
| 185 | - $params['itemId'] = $entity_service->get_uri( $entity_being_edited->ID ); |
|
| 186 | - |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - // Finally output the params as `wlSettings` for JavaScript code. |
|
| 190 | - wp_localize_script( $this->plugin_name, 'wlSettings', $params ); |
|
| 191 | - |
|
| 192 | - } |
|
| 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 | + * The {@link Wordlift_Configuration_Service} instance. |
|
| 45 | + * |
|
| 46 | + * @since 3.14.0 |
|
| 47 | + * @access private |
|
| 48 | + * @var \Wordlift_Configuration_Service $configuration_service The {@link Wordlift_Configuration_Service} instance. |
|
| 49 | + */ |
|
| 50 | + private $configuration_service; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * The {@link Wordlift_User_Service} instance. |
|
| 54 | + * |
|
| 55 | + * @since 3.14.0 |
|
| 56 | + * @access private |
|
| 57 | + * @var \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
| 58 | + */ |
|
| 59 | + private $user_service; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Initialize the class and set its properties. |
|
| 63 | + * |
|
| 64 | + * @since 1.0.0 |
|
| 65 | + * |
|
| 66 | + * @param string $plugin_name The name of this plugin. |
|
| 67 | + * @param string $version The version of this plugin. |
|
| 68 | + * @param \Wordlift_Configuration_Service $configuration_service The configuration service. |
|
| 69 | + * @param \Wordlift_Notice_Service $notice_service The notice service. |
|
| 70 | + * @param \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
| 71 | + */ |
|
| 72 | + public function __construct( $plugin_name, $version, $configuration_service, $notice_service, $user_service ) { |
|
| 73 | + |
|
| 74 | + $this->plugin_name = $plugin_name; |
|
| 75 | + $this->version = $version; |
|
| 76 | + |
|
| 77 | + $this->configuration_service = $configuration_service; |
|
| 78 | + $this->user_service = $user_service; |
|
| 79 | + |
|
| 80 | + $dataset_uri = $configuration_service->get_dataset_uri(); |
|
| 81 | + $key = $configuration_service->get_key(); |
|
| 82 | + |
|
| 83 | + if ( empty( $dataset_uri ) ) { |
|
| 84 | + $settings_page = Wordlift_Admin_Settings_Page::get_instance(); |
|
| 85 | + if ( empty( $key ) ) { |
|
| 86 | + $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>' ); |
|
| 87 | + } else { |
|
| 88 | + $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>' ); |
|
| 89 | + } |
|
| 90 | + $notice_service->add_error( $error ); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // Load additional code if we're in the admin UI. |
|
| 94 | + if ( is_admin() ) { |
|
| 95 | + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard-latest-news.php'; |
|
| 96 | + |
|
| 97 | + new Wordlift_Dashboard_Latest_News(); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Register the stylesheets for the admin area. |
|
| 104 | + * |
|
| 105 | + * @since 1.0.0 |
|
| 106 | + */ |
|
| 107 | + public function enqueue_styles() { |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * This function is provided for demonstration purposes only. |
|
| 111 | + * |
|
| 112 | + * An instance of this class should be passed to the run() function |
|
| 113 | + * defined in Wordlift_Loader as all of the hooks are defined |
|
| 114 | + * in that particular class. |
|
| 115 | + * |
|
| 116 | + * The Wordlift_Loader will then create the relationship |
|
| 117 | + * between the defined hooks and the functions defined in this |
|
| 118 | + * class. |
|
| 119 | + */ |
|
| 120 | + |
|
| 121 | + wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-admin.css', array(), $this->version, 'all' ); |
|
| 122 | + |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Register the JavaScript for the admin area. |
|
| 127 | + * |
|
| 128 | + * @since 1.0.0 |
|
| 129 | + */ |
|
| 130 | + public function enqueue_scripts() { |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * This function is provided for demonstration purposes only. |
|
| 134 | + * |
|
| 135 | + * An instance of this class should be passed to the run() function |
|
| 136 | + * defined in Wordlift_Loader as all of the hooks are defined |
|
| 137 | + * in that particular class. |
|
| 138 | + * |
|
| 139 | + * The Wordlift_Loader will then create the relationship |
|
| 140 | + * between the defined hooks and the functions defined in this |
|
| 141 | + * class. |
|
| 142 | + */ |
|
| 143 | + |
|
| 144 | + // Enqueue the admin scripts. |
|
| 145 | + wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/1/admin.js', array( |
|
| 146 | + 'jquery', |
|
| 147 | + 'underscore', |
|
| 148 | + 'backbone', |
|
| 149 | + ), $this->version, false ); |
|
| 150 | + |
|
| 151 | + // Set the basic params. |
|
| 152 | + $params = array( |
|
| 153 | + // @todo scripts in admin should use wp.post. |
|
| 154 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 155 | + // @todo remove specific actions from settings. |
|
| 156 | + 'action' => 'entity_by_title', |
|
| 157 | + 'datasetUri' => $this->configuration_service->get_dataset_uri(), |
|
| 158 | + 'language' => $this->configuration_service->get_language_code(), |
|
| 159 | + 'link_by_default' => $this->configuration_service->is_link_by_default(), |
|
| 160 | + // Whether the current user is allowed to create new entities. |
|
| 161 | + // |
|
| 162 | + // @see https://github.com/insideout10/wordlift-plugin/issues/561 |
|
| 163 | + 'can_create_entities' => current_user_can( 'edit_wordlift_entities' ) ? 'yes' : 'no', |
|
| 164 | + 'l10n' => array( |
|
| 165 | + 'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ), |
|
| 166 | + 'logo_selection_title' => __( 'WordLift Choose Logo', 'wordlift' ), |
|
| 167 | + 'logo_selection_button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ), |
|
| 168 | + 'Type at least 3 characters to search...' => _x( 'Type at least 3 characters to search...', 'Autocomplete Select', 'wordlift' ), |
|
| 169 | + 'No results found for your search.' => _x( 'No results found: try changing or removing some words.', 'Autocomplete Select', 'wordlift' ), |
|
| 170 | + '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' ), |
|
| 171 | + ), |
|
| 172 | + 'wl_autocomplete_nonce' => wp_create_nonce( 'wordlift_autocomplete' ), |
|
| 173 | + ); |
|
| 174 | + |
|
| 175 | + // Set post-related values if there's a current post. |
|
| 176 | + if ( null !== $post = $entity_being_edited = get_post() ) { |
|
| 177 | + |
|
| 178 | + $params['post_id'] = $entity_being_edited->ID; |
|
| 179 | + $entity_service = Wordlift_Entity_Service::get_instance(); |
|
| 180 | + $params['entityBeingEdited'] = isset( $entity_being_edited->post_type ) && $entity_service->is_entity( $post->ID ) && is_numeric( get_the_ID() ); |
|
| 181 | + // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it |
|
| 182 | + // from the results, since we don't want the current entity to be discovered by the analysis. |
|
| 183 | + // |
|
| 184 | + // See https://github.com/insideout10/wordlift-plugin/issues/345 |
|
| 185 | + $params['itemId'] = $entity_service->get_uri( $entity_being_edited->ID ); |
|
| 186 | + |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + // Finally output the params as `wlSettings` for JavaScript code. |
|
| 190 | + wp_localize_script( $this->plugin_name, 'wlSettings', $params ); |
|
| 191 | + |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param \Wordlift_Notice_Service $notice_service The notice service. |
| 70 | 70 | * @param \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
| 71 | 71 | */ |
| 72 | - public function __construct( $plugin_name, $version, $configuration_service, $notice_service, $user_service ) { |
|
| 72 | + public function __construct($plugin_name, $version, $configuration_service, $notice_service, $user_service) { |
|
| 73 | 73 | |
| 74 | 74 | $this->plugin_name = $plugin_name; |
| 75 | 75 | $this->version = $version; |
@@ -80,19 +80,19 @@ discard block |
||
| 80 | 80 | $dataset_uri = $configuration_service->get_dataset_uri(); |
| 81 | 81 | $key = $configuration_service->get_key(); |
| 82 | 82 | |
| 83 | - if ( empty( $dataset_uri ) ) { |
|
| 83 | + if (empty($dataset_uri)) { |
|
| 84 | 84 | $settings_page = Wordlift_Admin_Settings_Page::get_instance(); |
| 85 | - if ( empty( $key ) ) { |
|
| 86 | - $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>' ); |
|
| 85 | + if (empty($key)) { |
|
| 86 | + $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>'); |
|
| 87 | 87 | } else { |
| 88 | - $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>' ); |
|
| 88 | + $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>'); |
|
| 89 | 89 | } |
| 90 | - $notice_service->add_error( $error ); |
|
| 90 | + $notice_service->add_error($error); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // Load additional code if we're in the admin UI. |
| 94 | - if ( is_admin() ) { |
|
| 95 | - require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wordlift-admin-dashboard-latest-news.php'; |
|
| 94 | + if (is_admin()) { |
|
| 95 | + require_once plugin_dir_path(dirname(__FILE__)).'admin/class-wordlift-admin-dashboard-latest-news.php'; |
|
| 96 | 96 | |
| 97 | 97 | new Wordlift_Dashboard_Latest_News(); |
| 98 | 98 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * class. |
| 119 | 119 | */ |
| 120 | 120 | |
| 121 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-admin.css', array(), $this->version, 'all' ); |
|
| 121 | + wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/wordlift-admin.css', array(), $this->version, 'all'); |
|
| 122 | 122 | |
| 123 | 123 | } |
| 124 | 124 | |
@@ -142,16 +142,16 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | |
| 144 | 144 | // Enqueue the admin scripts. |
| 145 | - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/1/admin.js', array( |
|
| 145 | + wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/1/admin.js', array( |
|
| 146 | 146 | 'jquery', |
| 147 | 147 | 'underscore', |
| 148 | 148 | 'backbone', |
| 149 | - ), $this->version, false ); |
|
| 149 | + ), $this->version, false); |
|
| 150 | 150 | |
| 151 | 151 | // Set the basic params. |
| 152 | 152 | $params = array( |
| 153 | 153 | // @todo scripts in admin should use wp.post. |
| 154 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 154 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 155 | 155 | // @todo remove specific actions from settings. |
| 156 | 156 | 'action' => 'entity_by_title', |
| 157 | 157 | 'datasetUri' => $this->configuration_service->get_dataset_uri(), |
@@ -160,34 +160,34 @@ discard block |
||
| 160 | 160 | // Whether the current user is allowed to create new entities. |
| 161 | 161 | // |
| 162 | 162 | // @see https://github.com/insideout10/wordlift-plugin/issues/561 |
| 163 | - 'can_create_entities' => current_user_can( 'edit_wordlift_entities' ) ? 'yes' : 'no', |
|
| 163 | + 'can_create_entities' => current_user_can('edit_wordlift_entities') ? 'yes' : 'no', |
|
| 164 | 164 | 'l10n' => array( |
| 165 | - 'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ), |
|
| 166 | - 'logo_selection_title' => __( 'WordLift Choose Logo', 'wordlift' ), |
|
| 167 | - 'logo_selection_button' => array( 'text' => __( 'Choose Logo', 'wordlift' ) ), |
|
| 168 | - 'Type at least 3 characters to search...' => _x( 'Type at least 3 characters to search...', 'Autocomplete Select', 'wordlift' ), |
|
| 169 | - 'No results found for your search.' => _x( 'No results found: try changing or removing some words.', 'Autocomplete Select', 'wordlift' ), |
|
| 170 | - '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' ), |
|
| 165 | + 'You already published an entity with the same name' => __('You already published an entity with the same name: ', 'wordlift'), |
|
| 166 | + 'logo_selection_title' => __('WordLift Choose Logo', 'wordlift'), |
|
| 167 | + 'logo_selection_button' => array('text' => __('Choose Logo', 'wordlift')), |
|
| 168 | + 'Type at least 3 characters to search...' => _x('Type at least 3 characters to search...', 'Autocomplete Select', 'wordlift'), |
|
| 169 | + 'No results found for your search.' => _x('No results found: try changing or removing some words.', 'Autocomplete Select', 'wordlift'), |
|
| 170 | + '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'), |
|
| 171 | 171 | ), |
| 172 | - 'wl_autocomplete_nonce' => wp_create_nonce( 'wordlift_autocomplete' ), |
|
| 172 | + 'wl_autocomplete_nonce' => wp_create_nonce('wordlift_autocomplete'), |
|
| 173 | 173 | ); |
| 174 | 174 | |
| 175 | 175 | // Set post-related values if there's a current post. |
| 176 | - if ( null !== $post = $entity_being_edited = get_post() ) { |
|
| 176 | + if (null !== $post = $entity_being_edited = get_post()) { |
|
| 177 | 177 | |
| 178 | 178 | $params['post_id'] = $entity_being_edited->ID; |
| 179 | 179 | $entity_service = Wordlift_Entity_Service::get_instance(); |
| 180 | - $params['entityBeingEdited'] = isset( $entity_being_edited->post_type ) && $entity_service->is_entity( $post->ID ) && is_numeric( get_the_ID() ); |
|
| 180 | + $params['entityBeingEdited'] = isset($entity_being_edited->post_type) && $entity_service->is_entity($post->ID) && is_numeric(get_the_ID()); |
|
| 181 | 181 | // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it |
| 182 | 182 | // from the results, since we don't want the current entity to be discovered by the analysis. |
| 183 | 183 | // |
| 184 | 184 | // See https://github.com/insideout10/wordlift-plugin/issues/345 |
| 185 | - $params['itemId'] = $entity_service->get_uri( $entity_being_edited->ID ); |
|
| 185 | + $params['itemId'] = $entity_service->get_uri($entity_being_edited->ID); |
|
| 186 | 186 | |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | // Finally output the params as `wlSettings` for JavaScript code. |
| 190 | - wp_localize_script( $this->plugin_name, 'wlSettings', $params ); |
|
| 190 | + wp_localize_script($this->plugin_name, 'wlSettings', $params); |
|
| 191 | 191 | |
| 192 | 192 | } |
| 193 | 193 | |
@@ -18,367 +18,367 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Admin_Settings_Page extends Wordlift_Admin_Page { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * A singleton instance of the Notice service. |
|
| 23 | - * |
|
| 24 | - * @since 3.2.0 |
|
| 25 | - * @access private |
|
| 26 | - * @var \Wordlift_Notice_Service $instance A singleton instance of the Notice service. |
|
| 27 | - */ |
|
| 28 | - private static $instance; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * A {@link Wordlift_Entity_Service} instance. |
|
| 32 | - * |
|
| 33 | - * @since 3.11.0 |
|
| 34 | - * @access private |
|
| 35 | - * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 36 | - */ |
|
| 37 | - private $entity_service; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * A {@link Wordlift_Configuration_Service} instance. |
|
| 41 | - * |
|
| 42 | - * @since 3.11.0 |
|
| 43 | - * @access private |
|
| 44 | - * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 45 | - */ |
|
| 46 | - private $configuration_service; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * A {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 50 | - * |
|
| 51 | - * @since 3.11.0 |
|
| 52 | - * @access private |
|
| 53 | - * @var \Wordlift_Admin_Input_Element $input_element An {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 54 | - */ |
|
| 55 | - private $input_element; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 59 | - * |
|
| 60 | - * @since 3.13.0 |
|
| 61 | - * @access protected |
|
| 62 | - * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 63 | - */ |
|
| 64 | - private $radio_input_element; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 68 | - * |
|
| 69 | - * @since 3.11.0 |
|
| 70 | - * @access private |
|
| 71 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 72 | - */ |
|
| 73 | - private $language_select_element; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 77 | - * |
|
| 78 | - * @since 3.11.0 |
|
| 79 | - * @access private |
|
| 80 | - * @var \Wordlift_Admin_Publisher_Element $publisher_element A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 81 | - */ |
|
| 82 | - private $publisher_element; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * Create a {@link Wordlift_Admin_Settings_Page} instance. |
|
| 86 | - * |
|
| 87 | - * @since 3.11.0 |
|
| 88 | - * |
|
| 89 | - * @param \Wordlift_Configuration_Service $configuration_service |
|
| 90 | - * @param \Wordlift_Entity_Service $entity_service |
|
| 91 | - * @param \Wordlift_Admin_Input_Element $input_element |
|
| 92 | - * @param \Wordlift_Admin_Language_Select_Element $language_select_element |
|
| 93 | - * @param \Wordlift_Admin_Publisher_Element $publisher_element |
|
| 94 | - * @param \Wordlift_Admin_Radio_Input_Element $radio_input_element |
|
| 95 | - */ |
|
| 96 | - function __construct( $configuration_service, $entity_service, $input_element, $language_select_element, $publisher_element, $radio_input_element ) { |
|
| 97 | - |
|
| 98 | - $this->configuration_service = $configuration_service; |
|
| 99 | - $this->entity_service = $entity_service; |
|
| 100 | - |
|
| 101 | - // Set a reference to the UI elements. |
|
| 102 | - $this->input_element = $input_element; |
|
| 103 | - $this->radio_input_element = $radio_input_element; |
|
| 104 | - $this->language_select_element = $language_select_element; |
|
| 105 | - $this->publisher_element = $publisher_element; |
|
| 106 | - |
|
| 107 | - self::$instance = $this; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Get the singleton instance of the Notice service. |
|
| 112 | - * |
|
| 113 | - * @since 3.14.0 |
|
| 114 | - * @return \Wordlift_Admin_Settings_Page The singleton instance of the settings page service. |
|
| 115 | - */ |
|
| 116 | - public static function get_instance() { |
|
| 117 | - |
|
| 118 | - return self::$instance; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * @inheritdoc |
|
| 123 | - */ |
|
| 124 | - function get_parent_slug() { |
|
| 125 | - |
|
| 126 | - return 'wl_admin_menu'; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @inheritdoc |
|
| 131 | - */ |
|
| 132 | - function get_capability() { |
|
| 133 | - |
|
| 134 | - return 'manage_options'; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * @inheritdoc |
|
| 139 | - */ |
|
| 140 | - function get_page_title() { |
|
| 141 | - |
|
| 142 | - return 'WorldLift Settings'; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * @inheritdoc |
|
| 147 | - */ |
|
| 148 | - function get_menu_title() { |
|
| 149 | - |
|
| 150 | - return 'Settings'; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * @inheritdoc |
|
| 155 | - */ |
|
| 156 | - function get_menu_slug() { |
|
| 157 | - |
|
| 158 | - return 'wl_configuration_admin_menu'; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * @inheritdoc |
|
| 163 | - */ |
|
| 164 | - function get_partial_name() { |
|
| 165 | - |
|
| 166 | - return 'wordlift-admin-settings-page.php'; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * @inheritdoc |
|
| 171 | - */ |
|
| 172 | - public function enqueue_scripts() { |
|
| 173 | - |
|
| 174 | - // Enqueue the media scripts to be used for the publisher's logo selection. |
|
| 175 | - wp_enqueue_media(); |
|
| 176 | - |
|
| 177 | - // JavaScript required for the settings page. |
|
| 178 | - // @todo: try to move to the `wordlift-admin.bundle.js`. |
|
| 179 | - wp_enqueue_script( 'wordlift-admin-settings-page', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/1/settings.js', array( 'wp-util' ) ); |
|
| 180 | - wp_enqueue_style( 'wordlift-admin-settings-page', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/1/settings.css' ); |
|
| 181 | - |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * Configure all the configuration parameters. |
|
| 186 | - * |
|
| 187 | - * Called by the *admin_init* hook. |
|
| 188 | - * |
|
| 189 | - * @since 3.11.0 |
|
| 190 | - */ |
|
| 191 | - function admin_init() { |
|
| 192 | - |
|
| 193 | - // Register WordLift's general settings, providing our own sanitize callback |
|
| 194 | - // which will also check whether the user filled the WL Publisher form. |
|
| 195 | - register_setting( |
|
| 196 | - 'wl_general_settings', |
|
| 197 | - 'wl_general_settings', |
|
| 198 | - array( $this, 'sanitize_callback', ) |
|
| 199 | - ); |
|
| 200 | - |
|
| 201 | - // Add the general settings section. |
|
| 202 | - add_settings_section( |
|
| 203 | - 'wl_general_settings_section', // ID used to identify this section and with which to register options. |
|
| 204 | - '', // Section header. |
|
| 205 | - '', // Callback used to render the description of the section. |
|
| 206 | - 'wl_general_settings' // Page on which to add this section of options. |
|
| 207 | - ); |
|
| 208 | - |
|
| 209 | - $key_args = array( |
|
| 210 | - 'id' => 'wl-key', |
|
| 211 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::KEY . ']', |
|
| 212 | - 'value' => $this->configuration_service->get_key(), |
|
| 213 | - 'description' => __( 'Insert the <a href="https://www.wordlift.io/blogger">WordLift Key</a> you received via email.', 'wordlift' ), |
|
| 214 | - ); |
|
| 215 | - |
|
| 216 | - // Before we were used to validate the key beforehand, but this means |
|
| 217 | - // an http call whenever a page is opened in the admin area. Therefore |
|
| 218 | - // we now leave the input `untouched`, leaving to the client to update |
|
| 219 | - // the `css_class`. |
|
| 220 | - // |
|
| 221 | - // See https://github.com/insideout10/wordlift-plugin/issues/669. |
|
| 222 | - $key_args['css_class'] = 'untouched'; |
|
| 223 | - |
|
| 224 | - // Add the `key` field. |
|
| 225 | - add_settings_field( |
|
| 226 | - 'wl-key', // Element id used to identify the field throughout the theme. |
|
| 227 | - __( 'WordLift Key', 'wordlift' ), // The label to the left of the option interface element. |
|
| 228 | - // The name of the function responsible for rendering the option interface. |
|
| 229 | - array( $this->input_element, 'render', ), |
|
| 230 | - 'wl_general_settings', // The page on which this option will be displayed. |
|
| 231 | - 'wl_general_settings_section', // The name of the section to which this field belongs. |
|
| 232 | - $key_args // The array of arguments to pass to the callback. In this case, just a description. |
|
| 233 | - ); |
|
| 234 | - |
|
| 235 | - // Entity Base Path input. |
|
| 236 | - $entity_base_path_args = array( |
|
| 237 | - // The array of arguments to pass to the callback. In this case, just a description. |
|
| 238 | - 'id' => 'wl-entity-base-path', |
|
| 239 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::ENTITY_BASE_PATH_KEY . ']', |
|
| 240 | - 'value' => $this->configuration_service->get_entity_base_path(), |
|
| 241 | - /* translators: Placeholders: %s - a link to FAQ's page. */ |
|
| 242 | - 'description' => sprintf( __( 'All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field above. Check our <a href="%s">FAQs</a> if you need more info.', 'wordlift' ), 'https://wordlift.io/wordlift-user-faqs/#10-why-and-how-should-i-customize-the-url-of-the-entity-pages-created-in-my-vocabulary' ), |
|
| 243 | - ); |
|
| 244 | - |
|
| 245 | - // The following call is very heavy on large web sites and is always run |
|
| 246 | - // also when not needed: |
|
| 247 | - // $entity_base_path_args['readonly'] = 0 < $this->entity_service->count(); |
|
| 248 | - // |
|
| 249 | - // It is now replaced by a filter to add the `readonly` flag to the |
|
| 250 | - // input element when this is actually rendered. |
|
| 251 | - add_filter( 'wl_admin_input_element_params', array( |
|
| 252 | - $this, |
|
| 253 | - 'entity_path_input_element_params', |
|
| 254 | - ) ); |
|
| 255 | - |
|
| 256 | - |
|
| 257 | - // Add the `wl_entity_base_path` field. |
|
| 258 | - add_settings_field( |
|
| 259 | - 'wl-entity-base-path', // ID used to identify the field throughout the theme |
|
| 260 | - __( 'Entity Base Path', 'wordlift' ), // The label to the left of the option interface element |
|
| 261 | - // The name of the function responsible for rendering the option interface |
|
| 262 | - array( $this->input_element, 'render', ), |
|
| 263 | - 'wl_general_settings', // The page on which this option will be displayed |
|
| 264 | - 'wl_general_settings_section', // The name of the section to which this field belongs |
|
| 265 | - $entity_base_path_args |
|
| 266 | - ); |
|
| 267 | - |
|
| 268 | - // Add the `language_name` field. |
|
| 269 | - add_settings_field( |
|
| 270 | - 'wl-site-language', |
|
| 271 | - __( 'Site Language', 'wordlift' ), |
|
| 272 | - array( $this->language_select_element, 'render' ), |
|
| 273 | - 'wl_general_settings', |
|
| 274 | - 'wl_general_settings_section', |
|
| 275 | - array( |
|
| 276 | - // The array of arguments to pass to the callback. In this case, just a description. |
|
| 277 | - 'id' => 'wl-site-language', |
|
| 278 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LANGUAGE . ']', |
|
| 279 | - 'value' => $this->configuration_service->get_language_code(), |
|
| 280 | - 'description' => __( 'Each WordLift Key can be used only in one language. Pick yours.', 'wordlift' ), |
|
| 281 | - ) |
|
| 282 | - ); |
|
| 283 | - |
|
| 284 | - // Add the `publisher` field. |
|
| 285 | - add_settings_field( |
|
| 286 | - 'wl-publisher-id', |
|
| 287 | - __( 'Publisher', 'wordlift' ), |
|
| 288 | - array( $this->publisher_element, 'render' ), |
|
| 289 | - 'wl_general_settings', |
|
| 290 | - 'wl_general_settings_section', |
|
| 291 | - array( |
|
| 292 | - 'id' => 'wl-publisher-id', |
|
| 293 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::PUBLISHER_ID . ']', |
|
| 294 | - ) |
|
| 295 | - ); |
|
| 296 | - |
|
| 297 | - // Add the `link by default` field. |
|
| 298 | - add_settings_field( |
|
| 299 | - 'wl-link-by-default', |
|
| 300 | - __( 'Link by Default', 'wordlift' ), |
|
| 301 | - array( $this->radio_input_element, 'render' ), |
|
| 302 | - 'wl_general_settings', |
|
| 303 | - 'wl_general_settings_section', |
|
| 304 | - array( |
|
| 305 | - 'id' => 'wl-link-by-default', |
|
| 306 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LINK_BY_DEFAULT . ']', |
|
| 307 | - 'value' => $this->configuration_service->is_link_by_default() ? 'yes' : 'no', |
|
| 308 | - 'description' => __( 'Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift' ), |
|
| 309 | - ) |
|
| 310 | - ); |
|
| 311 | - |
|
| 312 | - // Add the `diagnostic data` field. |
|
| 313 | - add_settings_field( |
|
| 314 | - 'wl-send-diagnostic', |
|
| 315 | - __( 'Send Diagnostic Data', 'wordlift' ), |
|
| 316 | - array( $this->radio_input_element, 'render' ), |
|
| 317 | - 'wl_general_settings', |
|
| 318 | - 'wl_general_settings_section', |
|
| 319 | - array( |
|
| 320 | - 'id' => 'wl-send-diagnostic', |
|
| 321 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::SEND_DIAGNOSTIC . ']', |
|
| 322 | - 'value' => 'yes' === $this->configuration_service->get_diagnostic_preferences() ? 'yes' : 'no', |
|
| 323 | - 'description' => __( 'Whether to send diagnostic data or not.', 'wordlift' ), |
|
| 324 | - ) |
|
| 325 | - ); |
|
| 326 | - |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * Filter the {@link Wordlift_Admin_Input_Element} in order to add the |
|
| 331 | - * `readonly` flag to the `wl-entity-base-path` input. |
|
| 332 | - * |
|
| 333 | - * @since 3.17.0 |
|
| 334 | - * |
|
| 335 | - * @param array $args An array of {@link Wordlift_Admin_Input_Element} parameters. |
|
| 336 | - * |
|
| 337 | - * @return array The updated array. |
|
| 338 | - */ |
|
| 339 | - public function entity_path_input_element_params( $args ) { |
|
| 340 | - |
|
| 341 | - // Bail out if it's not the `wl-entity-base-path`). |
|
| 342 | - if ( 'wl-entity-base-path' !== $args['id'] ) { |
|
| 343 | - return $args; |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - // Set the readonly flag according to the entities count. |
|
| 347 | - $args['readonly'] = 0 < $this->entity_service->count(); |
|
| 348 | - |
|
| 349 | - // Return the updated args. |
|
| 350 | - return $args; |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * Sanitize the configuration settings to be stored. |
|
| 355 | - * |
|
| 356 | - * If a new entity is being created for the publisher, create it and set The |
|
| 357 | - * publisher setting. |
|
| 358 | - * |
|
| 359 | - * @since 3.11.0 |
|
| 360 | - * |
|
| 361 | - * @param array $input The configuration settings array. |
|
| 362 | - * |
|
| 363 | - * @return array The sanitized input array. |
|
| 364 | - */ |
|
| 365 | - function sanitize_callback( $input ) { |
|
| 366 | - |
|
| 367 | - // Check whether a publisher name has been set. |
|
| 368 | - if ( isset( $_POST['wl_publisher'] ) && ! empty( $_POST['wl_publisher']['name'] ) ) { |
|
| 369 | - $name = $_POST['wl_publisher']['name']; |
|
| 370 | - $type = $_POST['wl_publisher']['type']; |
|
| 371 | - $thumbnail_id = $_POST['wl_publisher']['thumbnail_id'] ?: null; |
|
| 372 | - |
|
| 373 | - // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
| 374 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person' ); |
|
| 375 | - |
|
| 376 | - // Create an entity for the publisher and assign it to the input |
|
| 377 | - // parameter which WordPress automatically saves into the settings. |
|
| 378 | - $input['publisher_id'] = $this->entity_service->create( $name, $type_uri, $thumbnail_id, 'publish' ); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - return $input; |
|
| 382 | - } |
|
| 21 | + /** |
|
| 22 | + * A singleton instance of the Notice service. |
|
| 23 | + * |
|
| 24 | + * @since 3.2.0 |
|
| 25 | + * @access private |
|
| 26 | + * @var \Wordlift_Notice_Service $instance A singleton instance of the Notice service. |
|
| 27 | + */ |
|
| 28 | + private static $instance; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * A {@link Wordlift_Entity_Service} instance. |
|
| 32 | + * |
|
| 33 | + * @since 3.11.0 |
|
| 34 | + * @access private |
|
| 35 | + * @var \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 36 | + */ |
|
| 37 | + private $entity_service; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * A {@link Wordlift_Configuration_Service} instance. |
|
| 41 | + * |
|
| 42 | + * @since 3.11.0 |
|
| 43 | + * @access private |
|
| 44 | + * @var \Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 45 | + */ |
|
| 46 | + private $configuration_service; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * A {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 50 | + * |
|
| 51 | + * @since 3.11.0 |
|
| 52 | + * @access private |
|
| 53 | + * @var \Wordlift_Admin_Input_Element $input_element An {@link Wordlift_Admin_Input_Element} element renderer. |
|
| 54 | + */ |
|
| 55 | + private $input_element; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 59 | + * |
|
| 60 | + * @since 3.13.0 |
|
| 61 | + * @access protected |
|
| 62 | + * @var \Wordlift_Admin_Radio_Input_Element $radio_input_element A {@link Wordlift_Admin_Radio_Input_Element} element renderer. |
|
| 63 | + */ |
|
| 64 | + private $radio_input_element; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 68 | + * |
|
| 69 | + * @since 3.11.0 |
|
| 70 | + * @access private |
|
| 71 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 72 | + */ |
|
| 73 | + private $language_select_element; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 77 | + * |
|
| 78 | + * @since 3.11.0 |
|
| 79 | + * @access private |
|
| 80 | + * @var \Wordlift_Admin_Publisher_Element $publisher_element A {@link Wordlift_Admin_Publisher_Element} element renderer. |
|
| 81 | + */ |
|
| 82 | + private $publisher_element; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * Create a {@link Wordlift_Admin_Settings_Page} instance. |
|
| 86 | + * |
|
| 87 | + * @since 3.11.0 |
|
| 88 | + * |
|
| 89 | + * @param \Wordlift_Configuration_Service $configuration_service |
|
| 90 | + * @param \Wordlift_Entity_Service $entity_service |
|
| 91 | + * @param \Wordlift_Admin_Input_Element $input_element |
|
| 92 | + * @param \Wordlift_Admin_Language_Select_Element $language_select_element |
|
| 93 | + * @param \Wordlift_Admin_Publisher_Element $publisher_element |
|
| 94 | + * @param \Wordlift_Admin_Radio_Input_Element $radio_input_element |
|
| 95 | + */ |
|
| 96 | + function __construct( $configuration_service, $entity_service, $input_element, $language_select_element, $publisher_element, $radio_input_element ) { |
|
| 97 | + |
|
| 98 | + $this->configuration_service = $configuration_service; |
|
| 99 | + $this->entity_service = $entity_service; |
|
| 100 | + |
|
| 101 | + // Set a reference to the UI elements. |
|
| 102 | + $this->input_element = $input_element; |
|
| 103 | + $this->radio_input_element = $radio_input_element; |
|
| 104 | + $this->language_select_element = $language_select_element; |
|
| 105 | + $this->publisher_element = $publisher_element; |
|
| 106 | + |
|
| 107 | + self::$instance = $this; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Get the singleton instance of the Notice service. |
|
| 112 | + * |
|
| 113 | + * @since 3.14.0 |
|
| 114 | + * @return \Wordlift_Admin_Settings_Page The singleton instance of the settings page service. |
|
| 115 | + */ |
|
| 116 | + public static function get_instance() { |
|
| 117 | + |
|
| 118 | + return self::$instance; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * @inheritdoc |
|
| 123 | + */ |
|
| 124 | + function get_parent_slug() { |
|
| 125 | + |
|
| 126 | + return 'wl_admin_menu'; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @inheritdoc |
|
| 131 | + */ |
|
| 132 | + function get_capability() { |
|
| 133 | + |
|
| 134 | + return 'manage_options'; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * @inheritdoc |
|
| 139 | + */ |
|
| 140 | + function get_page_title() { |
|
| 141 | + |
|
| 142 | + return 'WorldLift Settings'; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * @inheritdoc |
|
| 147 | + */ |
|
| 148 | + function get_menu_title() { |
|
| 149 | + |
|
| 150 | + return 'Settings'; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * @inheritdoc |
|
| 155 | + */ |
|
| 156 | + function get_menu_slug() { |
|
| 157 | + |
|
| 158 | + return 'wl_configuration_admin_menu'; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * @inheritdoc |
|
| 163 | + */ |
|
| 164 | + function get_partial_name() { |
|
| 165 | + |
|
| 166 | + return 'wordlift-admin-settings-page.php'; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * @inheritdoc |
|
| 171 | + */ |
|
| 172 | + public function enqueue_scripts() { |
|
| 173 | + |
|
| 174 | + // Enqueue the media scripts to be used for the publisher's logo selection. |
|
| 175 | + wp_enqueue_media(); |
|
| 176 | + |
|
| 177 | + // JavaScript required for the settings page. |
|
| 178 | + // @todo: try to move to the `wordlift-admin.bundle.js`. |
|
| 179 | + wp_enqueue_script( 'wordlift-admin-settings-page', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/1/settings.js', array( 'wp-util' ) ); |
|
| 180 | + wp_enqueue_style( 'wordlift-admin-settings-page', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/1/settings.css' ); |
|
| 181 | + |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * Configure all the configuration parameters. |
|
| 186 | + * |
|
| 187 | + * Called by the *admin_init* hook. |
|
| 188 | + * |
|
| 189 | + * @since 3.11.0 |
|
| 190 | + */ |
|
| 191 | + function admin_init() { |
|
| 192 | + |
|
| 193 | + // Register WordLift's general settings, providing our own sanitize callback |
|
| 194 | + // which will also check whether the user filled the WL Publisher form. |
|
| 195 | + register_setting( |
|
| 196 | + 'wl_general_settings', |
|
| 197 | + 'wl_general_settings', |
|
| 198 | + array( $this, 'sanitize_callback', ) |
|
| 199 | + ); |
|
| 200 | + |
|
| 201 | + // Add the general settings section. |
|
| 202 | + add_settings_section( |
|
| 203 | + 'wl_general_settings_section', // ID used to identify this section and with which to register options. |
|
| 204 | + '', // Section header. |
|
| 205 | + '', // Callback used to render the description of the section. |
|
| 206 | + 'wl_general_settings' // Page on which to add this section of options. |
|
| 207 | + ); |
|
| 208 | + |
|
| 209 | + $key_args = array( |
|
| 210 | + 'id' => 'wl-key', |
|
| 211 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::KEY . ']', |
|
| 212 | + 'value' => $this->configuration_service->get_key(), |
|
| 213 | + 'description' => __( 'Insert the <a href="https://www.wordlift.io/blogger">WordLift Key</a> you received via email.', 'wordlift' ), |
|
| 214 | + ); |
|
| 215 | + |
|
| 216 | + // Before we were used to validate the key beforehand, but this means |
|
| 217 | + // an http call whenever a page is opened in the admin area. Therefore |
|
| 218 | + // we now leave the input `untouched`, leaving to the client to update |
|
| 219 | + // the `css_class`. |
|
| 220 | + // |
|
| 221 | + // See https://github.com/insideout10/wordlift-plugin/issues/669. |
|
| 222 | + $key_args['css_class'] = 'untouched'; |
|
| 223 | + |
|
| 224 | + // Add the `key` field. |
|
| 225 | + add_settings_field( |
|
| 226 | + 'wl-key', // Element id used to identify the field throughout the theme. |
|
| 227 | + __( 'WordLift Key', 'wordlift' ), // The label to the left of the option interface element. |
|
| 228 | + // The name of the function responsible for rendering the option interface. |
|
| 229 | + array( $this->input_element, 'render', ), |
|
| 230 | + 'wl_general_settings', // The page on which this option will be displayed. |
|
| 231 | + 'wl_general_settings_section', // The name of the section to which this field belongs. |
|
| 232 | + $key_args // The array of arguments to pass to the callback. In this case, just a description. |
|
| 233 | + ); |
|
| 234 | + |
|
| 235 | + // Entity Base Path input. |
|
| 236 | + $entity_base_path_args = array( |
|
| 237 | + // The array of arguments to pass to the callback. In this case, just a description. |
|
| 238 | + 'id' => 'wl-entity-base-path', |
|
| 239 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::ENTITY_BASE_PATH_KEY . ']', |
|
| 240 | + 'value' => $this->configuration_service->get_entity_base_path(), |
|
| 241 | + /* translators: Placeholders: %s - a link to FAQ's page. */ |
|
| 242 | + 'description' => sprintf( __( 'All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field above. Check our <a href="%s">FAQs</a> if you need more info.', 'wordlift' ), 'https://wordlift.io/wordlift-user-faqs/#10-why-and-how-should-i-customize-the-url-of-the-entity-pages-created-in-my-vocabulary' ), |
|
| 243 | + ); |
|
| 244 | + |
|
| 245 | + // The following call is very heavy on large web sites and is always run |
|
| 246 | + // also when not needed: |
|
| 247 | + // $entity_base_path_args['readonly'] = 0 < $this->entity_service->count(); |
|
| 248 | + // |
|
| 249 | + // It is now replaced by a filter to add the `readonly` flag to the |
|
| 250 | + // input element when this is actually rendered. |
|
| 251 | + add_filter( 'wl_admin_input_element_params', array( |
|
| 252 | + $this, |
|
| 253 | + 'entity_path_input_element_params', |
|
| 254 | + ) ); |
|
| 255 | + |
|
| 256 | + |
|
| 257 | + // Add the `wl_entity_base_path` field. |
|
| 258 | + add_settings_field( |
|
| 259 | + 'wl-entity-base-path', // ID used to identify the field throughout the theme |
|
| 260 | + __( 'Entity Base Path', 'wordlift' ), // The label to the left of the option interface element |
|
| 261 | + // The name of the function responsible for rendering the option interface |
|
| 262 | + array( $this->input_element, 'render', ), |
|
| 263 | + 'wl_general_settings', // The page on which this option will be displayed |
|
| 264 | + 'wl_general_settings_section', // The name of the section to which this field belongs |
|
| 265 | + $entity_base_path_args |
|
| 266 | + ); |
|
| 267 | + |
|
| 268 | + // Add the `language_name` field. |
|
| 269 | + add_settings_field( |
|
| 270 | + 'wl-site-language', |
|
| 271 | + __( 'Site Language', 'wordlift' ), |
|
| 272 | + array( $this->language_select_element, 'render' ), |
|
| 273 | + 'wl_general_settings', |
|
| 274 | + 'wl_general_settings_section', |
|
| 275 | + array( |
|
| 276 | + // The array of arguments to pass to the callback. In this case, just a description. |
|
| 277 | + 'id' => 'wl-site-language', |
|
| 278 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LANGUAGE . ']', |
|
| 279 | + 'value' => $this->configuration_service->get_language_code(), |
|
| 280 | + 'description' => __( 'Each WordLift Key can be used only in one language. Pick yours.', 'wordlift' ), |
|
| 281 | + ) |
|
| 282 | + ); |
|
| 283 | + |
|
| 284 | + // Add the `publisher` field. |
|
| 285 | + add_settings_field( |
|
| 286 | + 'wl-publisher-id', |
|
| 287 | + __( 'Publisher', 'wordlift' ), |
|
| 288 | + array( $this->publisher_element, 'render' ), |
|
| 289 | + 'wl_general_settings', |
|
| 290 | + 'wl_general_settings_section', |
|
| 291 | + array( |
|
| 292 | + 'id' => 'wl-publisher-id', |
|
| 293 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::PUBLISHER_ID . ']', |
|
| 294 | + ) |
|
| 295 | + ); |
|
| 296 | + |
|
| 297 | + // Add the `link by default` field. |
|
| 298 | + add_settings_field( |
|
| 299 | + 'wl-link-by-default', |
|
| 300 | + __( 'Link by Default', 'wordlift' ), |
|
| 301 | + array( $this->radio_input_element, 'render' ), |
|
| 302 | + 'wl_general_settings', |
|
| 303 | + 'wl_general_settings_section', |
|
| 304 | + array( |
|
| 305 | + 'id' => 'wl-link-by-default', |
|
| 306 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LINK_BY_DEFAULT . ']', |
|
| 307 | + 'value' => $this->configuration_service->is_link_by_default() ? 'yes' : 'no', |
|
| 308 | + 'description' => __( 'Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift' ), |
|
| 309 | + ) |
|
| 310 | + ); |
|
| 311 | + |
|
| 312 | + // Add the `diagnostic data` field. |
|
| 313 | + add_settings_field( |
|
| 314 | + 'wl-send-diagnostic', |
|
| 315 | + __( 'Send Diagnostic Data', 'wordlift' ), |
|
| 316 | + array( $this->radio_input_element, 'render' ), |
|
| 317 | + 'wl_general_settings', |
|
| 318 | + 'wl_general_settings_section', |
|
| 319 | + array( |
|
| 320 | + 'id' => 'wl-send-diagnostic', |
|
| 321 | + 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::SEND_DIAGNOSTIC . ']', |
|
| 322 | + 'value' => 'yes' === $this->configuration_service->get_diagnostic_preferences() ? 'yes' : 'no', |
|
| 323 | + 'description' => __( 'Whether to send diagnostic data or not.', 'wordlift' ), |
|
| 324 | + ) |
|
| 325 | + ); |
|
| 326 | + |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * Filter the {@link Wordlift_Admin_Input_Element} in order to add the |
|
| 331 | + * `readonly` flag to the `wl-entity-base-path` input. |
|
| 332 | + * |
|
| 333 | + * @since 3.17.0 |
|
| 334 | + * |
|
| 335 | + * @param array $args An array of {@link Wordlift_Admin_Input_Element} parameters. |
|
| 336 | + * |
|
| 337 | + * @return array The updated array. |
|
| 338 | + */ |
|
| 339 | + public function entity_path_input_element_params( $args ) { |
|
| 340 | + |
|
| 341 | + // Bail out if it's not the `wl-entity-base-path`). |
|
| 342 | + if ( 'wl-entity-base-path' !== $args['id'] ) { |
|
| 343 | + return $args; |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + // Set the readonly flag according to the entities count. |
|
| 347 | + $args['readonly'] = 0 < $this->entity_service->count(); |
|
| 348 | + |
|
| 349 | + // Return the updated args. |
|
| 350 | + return $args; |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * Sanitize the configuration settings to be stored. |
|
| 355 | + * |
|
| 356 | + * If a new entity is being created for the publisher, create it and set The |
|
| 357 | + * publisher setting. |
|
| 358 | + * |
|
| 359 | + * @since 3.11.0 |
|
| 360 | + * |
|
| 361 | + * @param array $input The configuration settings array. |
|
| 362 | + * |
|
| 363 | + * @return array The sanitized input array. |
|
| 364 | + */ |
|
| 365 | + function sanitize_callback( $input ) { |
|
| 366 | + |
|
| 367 | + // Check whether a publisher name has been set. |
|
| 368 | + if ( isset( $_POST['wl_publisher'] ) && ! empty( $_POST['wl_publisher']['name'] ) ) { |
|
| 369 | + $name = $_POST['wl_publisher']['name']; |
|
| 370 | + $type = $_POST['wl_publisher']['type']; |
|
| 371 | + $thumbnail_id = $_POST['wl_publisher']['thumbnail_id'] ?: null; |
|
| 372 | + |
|
| 373 | + // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
| 374 | + $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person' ); |
|
| 375 | + |
|
| 376 | + // Create an entity for the publisher and assign it to the input |
|
| 377 | + // parameter which WordPress automatically saves into the settings. |
|
| 378 | + $input['publisher_id'] = $this->entity_service->create( $name, $type_uri, $thumbnail_id, 'publish' ); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + return $input; |
|
| 382 | + } |
|
| 383 | 383 | |
| 384 | 384 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param \Wordlift_Admin_Publisher_Element $publisher_element |
| 94 | 94 | * @param \Wordlift_Admin_Radio_Input_Element $radio_input_element |
| 95 | 95 | */ |
| 96 | - function __construct( $configuration_service, $entity_service, $input_element, $language_select_element, $publisher_element, $radio_input_element ) { |
|
| 96 | + function __construct($configuration_service, $entity_service, $input_element, $language_select_element, $publisher_element, $radio_input_element) { |
|
| 97 | 97 | |
| 98 | 98 | $this->configuration_service = $configuration_service; |
| 99 | 99 | $this->entity_service = $entity_service; |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | // JavaScript required for the settings page. |
| 178 | 178 | // @todo: try to move to the `wordlift-admin.bundle.js`. |
| 179 | - wp_enqueue_script( 'wordlift-admin-settings-page', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/1/settings.js', array( 'wp-util' ) ); |
|
| 180 | - wp_enqueue_style( 'wordlift-admin-settings-page', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/1/settings.css' ); |
|
| 179 | + wp_enqueue_script('wordlift-admin-settings-page', plugin_dir_url(dirname(__FILE__)).'admin/js/1/settings.js', array('wp-util')); |
|
| 180 | + wp_enqueue_style('wordlift-admin-settings-page', plugin_dir_url(dirname(__FILE__)).'admin/js/1/settings.css'); |
|
| 181 | 181 | |
| 182 | 182 | } |
| 183 | 183 | |
@@ -195,22 +195,22 @@ discard block |
||
| 195 | 195 | register_setting( |
| 196 | 196 | 'wl_general_settings', |
| 197 | 197 | 'wl_general_settings', |
| 198 | - array( $this, 'sanitize_callback', ) |
|
| 198 | + array($this, 'sanitize_callback',) |
|
| 199 | 199 | ); |
| 200 | 200 | |
| 201 | 201 | // Add the general settings section. |
| 202 | 202 | add_settings_section( |
| 203 | 203 | 'wl_general_settings_section', // ID used to identify this section and with which to register options. |
| 204 | - '', // Section header. |
|
| 205 | - '', // Callback used to render the description of the section. |
|
| 204 | + '', // Section header. |
|
| 205 | + '', // Callback used to render the description of the section. |
|
| 206 | 206 | 'wl_general_settings' // Page on which to add this section of options. |
| 207 | 207 | ); |
| 208 | 208 | |
| 209 | 209 | $key_args = array( |
| 210 | 210 | 'id' => 'wl-key', |
| 211 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::KEY . ']', |
|
| 211 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::KEY.']', |
|
| 212 | 212 | 'value' => $this->configuration_service->get_key(), |
| 213 | - 'description' => __( 'Insert the <a href="https://www.wordlift.io/blogger">WordLift Key</a> you received via email.', 'wordlift' ), |
|
| 213 | + 'description' => __('Insert the <a href="https://www.wordlift.io/blogger">WordLift Key</a> you received via email.', 'wordlift'), |
|
| 214 | 214 | ); |
| 215 | 215 | |
| 216 | 216 | // Before we were used to validate the key beforehand, but this means |
@@ -223,12 +223,12 @@ discard block |
||
| 223 | 223 | |
| 224 | 224 | // Add the `key` field. |
| 225 | 225 | add_settings_field( |
| 226 | - 'wl-key', // Element id used to identify the field throughout the theme. |
|
| 227 | - __( 'WordLift Key', 'wordlift' ), // The label to the left of the option interface element. |
|
| 226 | + 'wl-key', // Element id used to identify the field throughout the theme. |
|
| 227 | + __('WordLift Key', 'wordlift'), // The label to the left of the option interface element. |
|
| 228 | 228 | // The name of the function responsible for rendering the option interface. |
| 229 | - array( $this->input_element, 'render', ), |
|
| 230 | - 'wl_general_settings', // The page on which this option will be displayed. |
|
| 231 | - 'wl_general_settings_section', // The name of the section to which this field belongs. |
|
| 229 | + array($this->input_element, 'render',), |
|
| 230 | + 'wl_general_settings', // The page on which this option will be displayed. |
|
| 231 | + 'wl_general_settings_section', // The name of the section to which this field belongs. |
|
| 232 | 232 | $key_args // The array of arguments to pass to the callback. In this case, just a description. |
| 233 | 233 | ); |
| 234 | 234 | |
@@ -236,10 +236,10 @@ discard block |
||
| 236 | 236 | $entity_base_path_args = array( |
| 237 | 237 | // The array of arguments to pass to the callback. In this case, just a description. |
| 238 | 238 | 'id' => 'wl-entity-base-path', |
| 239 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::ENTITY_BASE_PATH_KEY . ']', |
|
| 239 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::ENTITY_BASE_PATH_KEY.']', |
|
| 240 | 240 | 'value' => $this->configuration_service->get_entity_base_path(), |
| 241 | 241 | /* translators: Placeholders: %s - a link to FAQ's page. */ |
| 242 | - 'description' => sprintf( __( 'All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field above. Check our <a href="%s">FAQs</a> if you need more info.', 'wordlift' ), 'https://wordlift.io/wordlift-user-faqs/#10-why-and-how-should-i-customize-the-url-of-the-entity-pages-created-in-my-vocabulary' ), |
|
| 242 | + 'description' => sprintf(__('All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field above. Check our <a href="%s">FAQs</a> if you need more info.', 'wordlift'), 'https://wordlift.io/wordlift-user-faqs/#10-why-and-how-should-i-customize-the-url-of-the-entity-pages-created-in-my-vocabulary'), |
|
| 243 | 243 | ); |
| 244 | 244 | |
| 245 | 245 | // The following call is very heavy on large web sites and is always run |
@@ -248,79 +248,79 @@ discard block |
||
| 248 | 248 | // |
| 249 | 249 | // It is now replaced by a filter to add the `readonly` flag to the |
| 250 | 250 | // input element when this is actually rendered. |
| 251 | - add_filter( 'wl_admin_input_element_params', array( |
|
| 251 | + add_filter('wl_admin_input_element_params', array( |
|
| 252 | 252 | $this, |
| 253 | 253 | 'entity_path_input_element_params', |
| 254 | - ) ); |
|
| 254 | + )); |
|
| 255 | 255 | |
| 256 | 256 | |
| 257 | 257 | // Add the `wl_entity_base_path` field. |
| 258 | 258 | add_settings_field( |
| 259 | - 'wl-entity-base-path', // ID used to identify the field throughout the theme |
|
| 260 | - __( 'Entity Base Path', 'wordlift' ), // The label to the left of the option interface element |
|
| 259 | + 'wl-entity-base-path', // ID used to identify the field throughout the theme |
|
| 260 | + __('Entity Base Path', 'wordlift'), // The label to the left of the option interface element |
|
| 261 | 261 | // The name of the function responsible for rendering the option interface |
| 262 | - array( $this->input_element, 'render', ), |
|
| 263 | - 'wl_general_settings', // The page on which this option will be displayed |
|
| 264 | - 'wl_general_settings_section', // The name of the section to which this field belongs |
|
| 262 | + array($this->input_element, 'render',), |
|
| 263 | + 'wl_general_settings', // The page on which this option will be displayed |
|
| 264 | + 'wl_general_settings_section', // The name of the section to which this field belongs |
|
| 265 | 265 | $entity_base_path_args |
| 266 | 266 | ); |
| 267 | 267 | |
| 268 | 268 | // Add the `language_name` field. |
| 269 | 269 | add_settings_field( |
| 270 | 270 | 'wl-site-language', |
| 271 | - __( 'Site Language', 'wordlift' ), |
|
| 272 | - array( $this->language_select_element, 'render' ), |
|
| 271 | + __('Site Language', 'wordlift'), |
|
| 272 | + array($this->language_select_element, 'render'), |
|
| 273 | 273 | 'wl_general_settings', |
| 274 | 274 | 'wl_general_settings_section', |
| 275 | 275 | array( |
| 276 | 276 | // The array of arguments to pass to the callback. In this case, just a description. |
| 277 | 277 | 'id' => 'wl-site-language', |
| 278 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LANGUAGE . ']', |
|
| 278 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::LANGUAGE.']', |
|
| 279 | 279 | 'value' => $this->configuration_service->get_language_code(), |
| 280 | - 'description' => __( 'Each WordLift Key can be used only in one language. Pick yours.', 'wordlift' ), |
|
| 280 | + 'description' => __('Each WordLift Key can be used only in one language. Pick yours.', 'wordlift'), |
|
| 281 | 281 | ) |
| 282 | 282 | ); |
| 283 | 283 | |
| 284 | 284 | // Add the `publisher` field. |
| 285 | 285 | add_settings_field( |
| 286 | 286 | 'wl-publisher-id', |
| 287 | - __( 'Publisher', 'wordlift' ), |
|
| 288 | - array( $this->publisher_element, 'render' ), |
|
| 287 | + __('Publisher', 'wordlift'), |
|
| 288 | + array($this->publisher_element, 'render'), |
|
| 289 | 289 | 'wl_general_settings', |
| 290 | 290 | 'wl_general_settings_section', |
| 291 | 291 | array( |
| 292 | 292 | 'id' => 'wl-publisher-id', |
| 293 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::PUBLISHER_ID . ']', |
|
| 293 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::PUBLISHER_ID.']', |
|
| 294 | 294 | ) |
| 295 | 295 | ); |
| 296 | 296 | |
| 297 | 297 | // Add the `link by default` field. |
| 298 | 298 | add_settings_field( |
| 299 | 299 | 'wl-link-by-default', |
| 300 | - __( 'Link by Default', 'wordlift' ), |
|
| 301 | - array( $this->radio_input_element, 'render' ), |
|
| 300 | + __('Link by Default', 'wordlift'), |
|
| 301 | + array($this->radio_input_element, 'render'), |
|
| 302 | 302 | 'wl_general_settings', |
| 303 | 303 | 'wl_general_settings_section', |
| 304 | 304 | array( |
| 305 | 305 | 'id' => 'wl-link-by-default', |
| 306 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::LINK_BY_DEFAULT . ']', |
|
| 306 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::LINK_BY_DEFAULT.']', |
|
| 307 | 307 | 'value' => $this->configuration_service->is_link_by_default() ? 'yes' : 'no', |
| 308 | - 'description' => __( 'Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift' ), |
|
| 308 | + 'description' => __('Whether to link entities by default or not. This setting applies to all the entities.', 'wordlift'), |
|
| 309 | 309 | ) |
| 310 | 310 | ); |
| 311 | 311 | |
| 312 | 312 | // Add the `diagnostic data` field. |
| 313 | 313 | add_settings_field( |
| 314 | 314 | 'wl-send-diagnostic', |
| 315 | - __( 'Send Diagnostic Data', 'wordlift' ), |
|
| 316 | - array( $this->radio_input_element, 'render' ), |
|
| 315 | + __('Send Diagnostic Data', 'wordlift'), |
|
| 316 | + array($this->radio_input_element, 'render'), |
|
| 317 | 317 | 'wl_general_settings', |
| 318 | 318 | 'wl_general_settings_section', |
| 319 | 319 | array( |
| 320 | 320 | 'id' => 'wl-send-diagnostic', |
| 321 | - 'name' => 'wl_general_settings[' . Wordlift_Configuration_Service::SEND_DIAGNOSTIC . ']', |
|
| 321 | + 'name' => 'wl_general_settings['.Wordlift_Configuration_Service::SEND_DIAGNOSTIC.']', |
|
| 322 | 322 | 'value' => 'yes' === $this->configuration_service->get_diagnostic_preferences() ? 'yes' : 'no', |
| 323 | - 'description' => __( 'Whether to send diagnostic data or not.', 'wordlift' ), |
|
| 323 | + 'description' => __('Whether to send diagnostic data or not.', 'wordlift'), |
|
| 324 | 324 | ) |
| 325 | 325 | ); |
| 326 | 326 | |
@@ -336,10 +336,10 @@ discard block |
||
| 336 | 336 | * |
| 337 | 337 | * @return array The updated array. |
| 338 | 338 | */ |
| 339 | - public function entity_path_input_element_params( $args ) { |
|
| 339 | + public function entity_path_input_element_params($args) { |
|
| 340 | 340 | |
| 341 | 341 | // Bail out if it's not the `wl-entity-base-path`). |
| 342 | - if ( 'wl-entity-base-path' !== $args['id'] ) { |
|
| 342 | + if ('wl-entity-base-path' !== $args['id']) { |
|
| 343 | 343 | return $args; |
| 344 | 344 | } |
| 345 | 345 | |
@@ -362,20 +362,20 @@ discard block |
||
| 362 | 362 | * |
| 363 | 363 | * @return array The sanitized input array. |
| 364 | 364 | */ |
| 365 | - function sanitize_callback( $input ) { |
|
| 365 | + function sanitize_callback($input) { |
|
| 366 | 366 | |
| 367 | 367 | // Check whether a publisher name has been set. |
| 368 | - if ( isset( $_POST['wl_publisher'] ) && ! empty( $_POST['wl_publisher']['name'] ) ) { |
|
| 368 | + if (isset($_POST['wl_publisher']) && ! empty($_POST['wl_publisher']['name'])) { |
|
| 369 | 369 | $name = $_POST['wl_publisher']['name']; |
| 370 | 370 | $type = $_POST['wl_publisher']['type']; |
| 371 | 371 | $thumbnail_id = $_POST['wl_publisher']['thumbnail_id'] ?: null; |
| 372 | 372 | |
| 373 | 373 | // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
| 374 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person' ); |
|
| 374 | + $type_uri = sprintf('http://schema.org/%s', 'organization' === $type ? 'Organization' : 'Person'); |
|
| 375 | 375 | |
| 376 | 376 | // Create an entity for the publisher and assign it to the input |
| 377 | 377 | // parameter which WordPress automatically saves into the settings. |
| 378 | - $input['publisher_id'] = $this->entity_service->create( $name, $type_uri, $thumbnail_id, 'publish' ); |
|
| 378 | + $input['publisher_id'] = $this->entity_service->create($name, $type_uri, $thumbnail_id, 'publish'); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | return $input; |
@@ -20,145 +20,145 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class Wordlift_Dashboard_Latest_News { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Add needed hooks for the latest news widget. |
|
| 25 | - */ |
|
| 26 | - public function __construct() { |
|
| 27 | - add_action( 'wp_ajax_wordlift_get_latest_news', array( |
|
| 28 | - $this, |
|
| 29 | - 'ajax_get_latest_news', |
|
| 30 | - ) ); |
|
| 31 | - add_action( 'wp_dashboard_setup', array( |
|
| 32 | - $this, |
|
| 33 | - 'add_dashboard_latest_news_widget', |
|
| 34 | - ) ); |
|
| 35 | - |
|
| 36 | - add_action( 'admin_enqueue_scripts', function () { |
|
| 37 | - wp_enqueue_script( 'wl-admin-dashboard', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/wordlift-admin-dashboard.js', array( 'jquery' ) ); |
|
| 38 | - } ); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Return latest news html. |
|
| 43 | - * |
|
| 44 | - * @return string Articles html markup. |
|
| 45 | - */ |
|
| 46 | - public function render() { |
|
| 47 | - include( plugin_dir_path( __FILE__ ) . 'partials/wordlift-admin-news-widget.php' ); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Returns latest news data filtered by $start_position. |
|
| 52 | - * |
|
| 53 | - * @param int $start_position (news array key start position). |
|
| 54 | - * |
|
| 55 | - * @return array Latest posts data. |
|
| 56 | - */ |
|
| 57 | - public function get_last_wordlift_articles( $start_position = 0 ) { |
|
| 58 | - $feed_articles = $this->get_wordlift_articles_data(); |
|
| 59 | - |
|
| 60 | - // Filter articles by $start_position |
|
| 61 | - if ( ! empty( $feed_articles ) ) { |
|
| 62 | - return array( |
|
| 63 | - 'posts_data' => array_slice( $feed_articles, $start_position, 3 ), |
|
| 64 | - 'count' => count( $feed_articles ), |
|
| 65 | - 'start_position' => $start_position, |
|
| 66 | - ); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - return false; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Returns latest news array data. |
|
| 74 | - * |
|
| 75 | - * @uses https://codex.wordpress.org/Function_Reference/fetch_feed |
|
| 76 | - * @uses https://codex.wordpress.org/Function_Reference/get_locale |
|
| 77 | - * |
|
| 78 | - * @param int $articles_number (articles total number). |
|
| 79 | - * |
|
| 80 | - * @return array Latest $articles_number feed posts. |
|
| 81 | - */ |
|
| 82 | - public function get_wordlift_articles_data( $articles_number = 10 ) { |
|
| 83 | - // Init cache class |
|
| 84 | - $cache_sistem_lib = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'articles/' ); |
|
| 85 | - $locale = get_locale(); |
|
| 86 | - $cache_id = 'news_' . date( 'Y_m_d' ) . '_' . $locale; |
|
| 87 | - $posts_data = array(); |
|
| 88 | - |
|
| 89 | - // Get latest articles from cache |
|
| 90 | - $feed_articles = $cache_sistem_lib->get_cache( $cache_id ); |
|
| 91 | - if ( false === $feed_articles ) { |
|
| 92 | - // Check wordpress installation language to define articles rss url |
|
| 93 | - $feed_uri = ( 'it_IT' === $locale ) ? 'https://wordlift.io/blog/it/feed/' : 'https://wordlift.io/blog/en/feed/'; |
|
| 94 | - |
|
| 95 | - // Get rss feed data, the response is cached by default for 12 hours |
|
| 96 | - $feed = fetch_feed( $feed_uri ); |
|
| 97 | - if ( ! is_wp_error( $feed ) ) { |
|
| 98 | - // Build an array of requested $articles_number, starting with element 0 |
|
| 99 | - $feed_articles = $feed->get_items( 0, $articles_number ); |
|
| 100 | - foreach ( $feed_articles as $key => $item ) { |
|
| 101 | - $data = array( |
|
| 102 | - // fetch_feed will return the title html decoded. |
|
| 103 | - 'post_title' => $item->get_title(), |
|
| 104 | - 'post_date' => $item->get_date( 'j F Y | g:i a' ), |
|
| 105 | - 'post_url' => self::add_utm_parameter( $item->get_permalink() ), |
|
| 106 | - // fetch_feed will return the description html (not decoded). |
|
| 107 | - 'post_description' => $item->get_description(), |
|
| 108 | - ); |
|
| 109 | - array_push( $posts_data, $data ); |
|
| 110 | - } |
|
| 111 | - // Set articles in cache. |
|
| 112 | - $cache_sistem_lib->set_cache( $cache_id, $posts_data ); |
|
| 113 | - $feed_articles = $posts_data; |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - return $feed_articles; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * Add the `utm` parameter for GA. |
|
| 122 | - * |
|
| 123 | - * @since 3.19.0 |
|
| 124 | - * |
|
| 125 | - * @param string $url The URL. |
|
| 126 | - * |
|
| 127 | - * @return string The URL with the `utm` parameter prepended by `&` or by `?`. |
|
| 128 | - */ |
|
| 129 | - private static function add_utm_parameter( $url ) { |
|
| 130 | - |
|
| 131 | - if ( false === strpos( $url, '?' ) ) { |
|
| 132 | - return $url . '?utm=wl_dash'; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - return $url . '&utm=wl_dash'; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * Ajax call for more latest news. |
|
| 140 | - * |
|
| 141 | - * @uses https://codex.wordpress.org/Function_Reference/wp_send_json_success |
|
| 142 | - * |
|
| 143 | - * @return string JSON obj with articles data. |
|
| 144 | - */ |
|
| 145 | - public function ajax_get_latest_news() { |
|
| 146 | - // Get wordlift articles |
|
| 147 | - $start_position = explode( '_', $_POST['more_posts_link_id'] ); |
|
| 148 | - $data = $this->get_last_wordlift_articles( $start_position[ count( $start_position ) - 1 ] ); |
|
| 149 | - |
|
| 150 | - // Return response as json object |
|
| 151 | - wp_send_json_success( $data ); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Add latest news widget to the administration dashboard. |
|
| 156 | - */ |
|
| 157 | - public function add_dashboard_latest_news_widget() { |
|
| 158 | - wp_add_dashboard_widget( 'wordlift-dashboard-latest-news-widget', 'Latest WordLift News', array( |
|
| 159 | - $this, |
|
| 160 | - 'render', |
|
| 161 | - ) ); |
|
| 162 | - } |
|
| 23 | + /** |
|
| 24 | + * Add needed hooks for the latest news widget. |
|
| 25 | + */ |
|
| 26 | + public function __construct() { |
|
| 27 | + add_action( 'wp_ajax_wordlift_get_latest_news', array( |
|
| 28 | + $this, |
|
| 29 | + 'ajax_get_latest_news', |
|
| 30 | + ) ); |
|
| 31 | + add_action( 'wp_dashboard_setup', array( |
|
| 32 | + $this, |
|
| 33 | + 'add_dashboard_latest_news_widget', |
|
| 34 | + ) ); |
|
| 35 | + |
|
| 36 | + add_action( 'admin_enqueue_scripts', function () { |
|
| 37 | + wp_enqueue_script( 'wl-admin-dashboard', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/wordlift-admin-dashboard.js', array( 'jquery' ) ); |
|
| 38 | + } ); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Return latest news html. |
|
| 43 | + * |
|
| 44 | + * @return string Articles html markup. |
|
| 45 | + */ |
|
| 46 | + public function render() { |
|
| 47 | + include( plugin_dir_path( __FILE__ ) . 'partials/wordlift-admin-news-widget.php' ); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Returns latest news data filtered by $start_position. |
|
| 52 | + * |
|
| 53 | + * @param int $start_position (news array key start position). |
|
| 54 | + * |
|
| 55 | + * @return array Latest posts data. |
|
| 56 | + */ |
|
| 57 | + public function get_last_wordlift_articles( $start_position = 0 ) { |
|
| 58 | + $feed_articles = $this->get_wordlift_articles_data(); |
|
| 59 | + |
|
| 60 | + // Filter articles by $start_position |
|
| 61 | + if ( ! empty( $feed_articles ) ) { |
|
| 62 | + return array( |
|
| 63 | + 'posts_data' => array_slice( $feed_articles, $start_position, 3 ), |
|
| 64 | + 'count' => count( $feed_articles ), |
|
| 65 | + 'start_position' => $start_position, |
|
| 66 | + ); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + return false; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Returns latest news array data. |
|
| 74 | + * |
|
| 75 | + * @uses https://codex.wordpress.org/Function_Reference/fetch_feed |
|
| 76 | + * @uses https://codex.wordpress.org/Function_Reference/get_locale |
|
| 77 | + * |
|
| 78 | + * @param int $articles_number (articles total number). |
|
| 79 | + * |
|
| 80 | + * @return array Latest $articles_number feed posts. |
|
| 81 | + */ |
|
| 82 | + public function get_wordlift_articles_data( $articles_number = 10 ) { |
|
| 83 | + // Init cache class |
|
| 84 | + $cache_sistem_lib = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'articles/' ); |
|
| 85 | + $locale = get_locale(); |
|
| 86 | + $cache_id = 'news_' . date( 'Y_m_d' ) . '_' . $locale; |
|
| 87 | + $posts_data = array(); |
|
| 88 | + |
|
| 89 | + // Get latest articles from cache |
|
| 90 | + $feed_articles = $cache_sistem_lib->get_cache( $cache_id ); |
|
| 91 | + if ( false === $feed_articles ) { |
|
| 92 | + // Check wordpress installation language to define articles rss url |
|
| 93 | + $feed_uri = ( 'it_IT' === $locale ) ? 'https://wordlift.io/blog/it/feed/' : 'https://wordlift.io/blog/en/feed/'; |
|
| 94 | + |
|
| 95 | + // Get rss feed data, the response is cached by default for 12 hours |
|
| 96 | + $feed = fetch_feed( $feed_uri ); |
|
| 97 | + if ( ! is_wp_error( $feed ) ) { |
|
| 98 | + // Build an array of requested $articles_number, starting with element 0 |
|
| 99 | + $feed_articles = $feed->get_items( 0, $articles_number ); |
|
| 100 | + foreach ( $feed_articles as $key => $item ) { |
|
| 101 | + $data = array( |
|
| 102 | + // fetch_feed will return the title html decoded. |
|
| 103 | + 'post_title' => $item->get_title(), |
|
| 104 | + 'post_date' => $item->get_date( 'j F Y | g:i a' ), |
|
| 105 | + 'post_url' => self::add_utm_parameter( $item->get_permalink() ), |
|
| 106 | + // fetch_feed will return the description html (not decoded). |
|
| 107 | + 'post_description' => $item->get_description(), |
|
| 108 | + ); |
|
| 109 | + array_push( $posts_data, $data ); |
|
| 110 | + } |
|
| 111 | + // Set articles in cache. |
|
| 112 | + $cache_sistem_lib->set_cache( $cache_id, $posts_data ); |
|
| 113 | + $feed_articles = $posts_data; |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + return $feed_articles; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * Add the `utm` parameter for GA. |
|
| 122 | + * |
|
| 123 | + * @since 3.19.0 |
|
| 124 | + * |
|
| 125 | + * @param string $url The URL. |
|
| 126 | + * |
|
| 127 | + * @return string The URL with the `utm` parameter prepended by `&` or by `?`. |
|
| 128 | + */ |
|
| 129 | + private static function add_utm_parameter( $url ) { |
|
| 130 | + |
|
| 131 | + if ( false === strpos( $url, '?' ) ) { |
|
| 132 | + return $url . '?utm=wl_dash'; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + return $url . '&utm=wl_dash'; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * Ajax call for more latest news. |
|
| 140 | + * |
|
| 141 | + * @uses https://codex.wordpress.org/Function_Reference/wp_send_json_success |
|
| 142 | + * |
|
| 143 | + * @return string JSON obj with articles data. |
|
| 144 | + */ |
|
| 145 | + public function ajax_get_latest_news() { |
|
| 146 | + // Get wordlift articles |
|
| 147 | + $start_position = explode( '_', $_POST['more_posts_link_id'] ); |
|
| 148 | + $data = $this->get_last_wordlift_articles( $start_position[ count( $start_position ) - 1 ] ); |
|
| 149 | + |
|
| 150 | + // Return response as json object |
|
| 151 | + wp_send_json_success( $data ); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Add latest news widget to the administration dashboard. |
|
| 156 | + */ |
|
| 157 | + public function add_dashboard_latest_news_widget() { |
|
| 158 | + wp_add_dashboard_widget( 'wordlift-dashboard-latest-news-widget', 'Latest WordLift News', array( |
|
| 159 | + $this, |
|
| 160 | + 'render', |
|
| 161 | + ) ); |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | 164 | } |
@@ -24,17 +24,17 @@ discard block |
||
| 24 | 24 | * Add needed hooks for the latest news widget. |
| 25 | 25 | */ |
| 26 | 26 | public function __construct() { |
| 27 | - add_action( 'wp_ajax_wordlift_get_latest_news', array( |
|
| 27 | + add_action('wp_ajax_wordlift_get_latest_news', array( |
|
| 28 | 28 | $this, |
| 29 | 29 | 'ajax_get_latest_news', |
| 30 | - ) ); |
|
| 31 | - add_action( 'wp_dashboard_setup', array( |
|
| 30 | + )); |
|
| 31 | + add_action('wp_dashboard_setup', array( |
|
| 32 | 32 | $this, |
| 33 | 33 | 'add_dashboard_latest_news_widget', |
| 34 | - ) ); |
|
| 34 | + )); |
|
| 35 | 35 | |
| 36 | - add_action( 'admin_enqueue_scripts', function () { |
|
| 37 | - wp_enqueue_script( 'wl-admin-dashboard', plugin_dir_url( dirname( __FILE__ ) ) . 'admin/js/wordlift-admin-dashboard.js', array( 'jquery' ) ); |
|
| 36 | + add_action('admin_enqueue_scripts', function() { |
|
| 37 | + wp_enqueue_script('wl-admin-dashboard', plugin_dir_url(dirname(__FILE__)).'admin/js/wordlift-admin-dashboard.js', array('jquery')); |
|
| 38 | 38 | } ); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @return string Articles html markup. |
| 45 | 45 | */ |
| 46 | 46 | public function render() { |
| 47 | - include( plugin_dir_path( __FILE__ ) . 'partials/wordlift-admin-news-widget.php' ); |
|
| 47 | + include(plugin_dir_path(__FILE__).'partials/wordlift-admin-news-widget.php'); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -54,14 +54,14 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @return array Latest posts data. |
| 56 | 56 | */ |
| 57 | - public function get_last_wordlift_articles( $start_position = 0 ) { |
|
| 57 | + public function get_last_wordlift_articles($start_position = 0) { |
|
| 58 | 58 | $feed_articles = $this->get_wordlift_articles_data(); |
| 59 | 59 | |
| 60 | 60 | // Filter articles by $start_position |
| 61 | - if ( ! empty( $feed_articles ) ) { |
|
| 61 | + if ( ! empty($feed_articles)) { |
|
| 62 | 62 | return array( |
| 63 | - 'posts_data' => array_slice( $feed_articles, $start_position, 3 ), |
|
| 64 | - 'count' => count( $feed_articles ), |
|
| 63 | + 'posts_data' => array_slice($feed_articles, $start_position, 3), |
|
| 64 | + 'count' => count($feed_articles), |
|
| 65 | 65 | 'start_position' => $start_position, |
| 66 | 66 | ); |
| 67 | 67 | } |
@@ -79,37 +79,37 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return array Latest $articles_number feed posts. |
| 81 | 81 | */ |
| 82 | - public function get_wordlift_articles_data( $articles_number = 10 ) { |
|
| 82 | + public function get_wordlift_articles_data($articles_number = 10) { |
|
| 83 | 83 | // Init cache class |
| 84 | - $cache_sistem_lib = new Wordlift_File_Cache_Service( WL_TEMP_DIR . 'articles/' ); |
|
| 84 | + $cache_sistem_lib = new Wordlift_File_Cache_Service(WL_TEMP_DIR.'articles/'); |
|
| 85 | 85 | $locale = get_locale(); |
| 86 | - $cache_id = 'news_' . date( 'Y_m_d' ) . '_' . $locale; |
|
| 86 | + $cache_id = 'news_'.date('Y_m_d').'_'.$locale; |
|
| 87 | 87 | $posts_data = array(); |
| 88 | 88 | |
| 89 | 89 | // Get latest articles from cache |
| 90 | - $feed_articles = $cache_sistem_lib->get_cache( $cache_id ); |
|
| 91 | - if ( false === $feed_articles ) { |
|
| 90 | + $feed_articles = $cache_sistem_lib->get_cache($cache_id); |
|
| 91 | + if (false === $feed_articles) { |
|
| 92 | 92 | // Check wordpress installation language to define articles rss url |
| 93 | - $feed_uri = ( 'it_IT' === $locale ) ? 'https://wordlift.io/blog/it/feed/' : 'https://wordlift.io/blog/en/feed/'; |
|
| 93 | + $feed_uri = ('it_IT' === $locale) ? 'https://wordlift.io/blog/it/feed/' : 'https://wordlift.io/blog/en/feed/'; |
|
| 94 | 94 | |
| 95 | 95 | // Get rss feed data, the response is cached by default for 12 hours |
| 96 | - $feed = fetch_feed( $feed_uri ); |
|
| 97 | - if ( ! is_wp_error( $feed ) ) { |
|
| 96 | + $feed = fetch_feed($feed_uri); |
|
| 97 | + if ( ! is_wp_error($feed)) { |
|
| 98 | 98 | // Build an array of requested $articles_number, starting with element 0 |
| 99 | - $feed_articles = $feed->get_items( 0, $articles_number ); |
|
| 100 | - foreach ( $feed_articles as $key => $item ) { |
|
| 99 | + $feed_articles = $feed->get_items(0, $articles_number); |
|
| 100 | + foreach ($feed_articles as $key => $item) { |
|
| 101 | 101 | $data = array( |
| 102 | 102 | // fetch_feed will return the title html decoded. |
| 103 | 103 | 'post_title' => $item->get_title(), |
| 104 | - 'post_date' => $item->get_date( 'j F Y | g:i a' ), |
|
| 105 | - 'post_url' => self::add_utm_parameter( $item->get_permalink() ), |
|
| 104 | + 'post_date' => $item->get_date('j F Y | g:i a'), |
|
| 105 | + 'post_url' => self::add_utm_parameter($item->get_permalink()), |
|
| 106 | 106 | // fetch_feed will return the description html (not decoded). |
| 107 | 107 | 'post_description' => $item->get_description(), |
| 108 | 108 | ); |
| 109 | - array_push( $posts_data, $data ); |
|
| 109 | + array_push($posts_data, $data); |
|
| 110 | 110 | } |
| 111 | 111 | // Set articles in cache. |
| 112 | - $cache_sistem_lib->set_cache( $cache_id, $posts_data ); |
|
| 112 | + $cache_sistem_lib->set_cache($cache_id, $posts_data); |
|
| 113 | 113 | $feed_articles = $posts_data; |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return string The URL with the `utm` parameter prepended by `&` or by `?`. |
| 128 | 128 | */ |
| 129 | - private static function add_utm_parameter( $url ) { |
|
| 129 | + private static function add_utm_parameter($url) { |
|
| 130 | 130 | |
| 131 | - if ( false === strpos( $url, '?' ) ) { |
|
| 132 | - return $url . '?utm=wl_dash'; |
|
| 131 | + if (false === strpos($url, '?')) { |
|
| 132 | + return $url.'?utm=wl_dash'; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - return $url . '&utm=wl_dash'; |
|
| 135 | + return $url.'&utm=wl_dash'; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
@@ -144,21 +144,21 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | public function ajax_get_latest_news() { |
| 146 | 146 | // Get wordlift articles |
| 147 | - $start_position = explode( '_', $_POST['more_posts_link_id'] ); |
|
| 148 | - $data = $this->get_last_wordlift_articles( $start_position[ count( $start_position ) - 1 ] ); |
|
| 147 | + $start_position = explode('_', $_POST['more_posts_link_id']); |
|
| 148 | + $data = $this->get_last_wordlift_articles($start_position[count($start_position) - 1]); |
|
| 149 | 149 | |
| 150 | 150 | // Return response as json object |
| 151 | - wp_send_json_success( $data ); |
|
| 151 | + wp_send_json_success($data); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | 155 | * Add latest news widget to the administration dashboard. |
| 156 | 156 | */ |
| 157 | 157 | public function add_dashboard_latest_news_widget() { |
| 158 | - wp_add_dashboard_widget( 'wordlift-dashboard-latest-news-widget', 'Latest WordLift News', array( |
|
| 158 | + wp_add_dashboard_widget('wordlift-dashboard-latest-news-widget', 'Latest WordLift News', array( |
|
| 159 | 159 | $this, |
| 160 | 160 | 'render', |
| 161 | - ) ); |
|
| 161 | + )); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | - exit; |
|
| 16 | + exit; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -28,106 +28,106 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | class Wordlift_Admin_Setup { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * A {@link Wordlift_Configuration_Service} instance. |
|
| 33 | - * |
|
| 34 | - * @since 3.9.0 |
|
| 35 | - * @access private |
|
| 36 | - * @var Wordlift_Configuration_Service A {@link Wordlift_Configuration_Service} instance. |
|
| 37 | - */ |
|
| 38 | - private $configuration_service; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 42 | - * |
|
| 43 | - * @since 3.9.0 |
|
| 44 | - * @access private |
|
| 45 | - * @var Wordlift_Key_Validation_Service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 46 | - */ |
|
| 47 | - private $key_validation_service; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * A {@link Wordlift_Entity_Service} instance. |
|
| 51 | - * |
|
| 52 | - * @since 3.9.0 |
|
| 53 | - * @access private |
|
| 54 | - * @var Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 55 | - */ |
|
| 56 | - private $entity_service; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Initialize the class and set its properties. |
|
| 60 | - * |
|
| 61 | - * @since 3.9.0 |
|
| 62 | - * |
|
| 63 | - * @param Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 64 | - * @param Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 65 | - * @param Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 66 | - */ |
|
| 67 | - public function __construct( $configuration_service, $key_validation_service, $entity_service ) { |
|
| 68 | - |
|
| 69 | - // Set a reference to the configuration service. |
|
| 70 | - $this->configuration_service = $configuration_service; |
|
| 71 | - |
|
| 72 | - // Set a reference to the key validation service. |
|
| 73 | - $this->key_validation_service = $key_validation_service; |
|
| 74 | - |
|
| 75 | - // Set a reference to the entity service. |
|
| 76 | - $this->entity_service = $entity_service; |
|
| 77 | - |
|
| 78 | - // Hook to some WP's events: |
|
| 79 | - // When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up. |
|
| 80 | - add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
| 81 | - |
|
| 82 | - // Hook to `admin_menu` in order to add our own setup wizard page. |
|
| 83 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 84 | - |
|
| 85 | - // Triggered when the user accesses the admin area, we decide whether to show our own wizard. |
|
| 86 | - add_action( 'admin_init', array( $this, 'show_page' ) ); |
|
| 87 | - |
|
| 88 | - // Hook to `admin_notices` to display our notices. |
|
| 89 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 90 | - |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Hook to `admin_init` and redirect to WordLift's setup page if the `_wl_activation_redirect` transient flag is set. |
|
| 95 | - * |
|
| 96 | - * @since 3.9.0 |
|
| 97 | - */ |
|
| 98 | - public function admin_init() { |
|
| 99 | - |
|
| 100 | - // If the `_wl_activation_redirect` is set, the redirect to the setup page. |
|
| 101 | - if ( get_transient( '_wl_activation_redirect' ) ) { |
|
| 102 | - delete_transient( '_wl_activation_redirect' ); |
|
| 103 | - |
|
| 104 | - // If the user asked to skip the wizard then comply. |
|
| 105 | - if ( $this->configuration_service->is_skip_wizard() ) { |
|
| 106 | - return; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - // If we're already on the page or the user doesn't have permissions, return. |
|
| 110 | - if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { |
|
| 111 | - return; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - // Finally redirect to the setup page. |
|
| 115 | - wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) ); |
|
| 116 | - |
|
| 117 | - exit; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Generate an admin notice suggesting to start the wizard if there is no configuration. |
|
| 124 | - * |
|
| 125 | - * @since 3.9.0 |
|
| 126 | - */ |
|
| 127 | - public function admin_notices() { |
|
| 128 | - |
|
| 129 | - // Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard. |
|
| 130 | - if ( '' === $this->configuration_service->get_key() && ! $this->configuration_service->is_skip_wizard() ) { ?> |
|
| 31 | + /** |
|
| 32 | + * A {@link Wordlift_Configuration_Service} instance. |
|
| 33 | + * |
|
| 34 | + * @since 3.9.0 |
|
| 35 | + * @access private |
|
| 36 | + * @var Wordlift_Configuration_Service A {@link Wordlift_Configuration_Service} instance. |
|
| 37 | + */ |
|
| 38 | + private $configuration_service; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 42 | + * |
|
| 43 | + * @since 3.9.0 |
|
| 44 | + * @access private |
|
| 45 | + * @var Wordlift_Key_Validation_Service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 46 | + */ |
|
| 47 | + private $key_validation_service; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * A {@link Wordlift_Entity_Service} instance. |
|
| 51 | + * |
|
| 52 | + * @since 3.9.0 |
|
| 53 | + * @access private |
|
| 54 | + * @var Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 55 | + */ |
|
| 56 | + private $entity_service; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Initialize the class and set its properties. |
|
| 60 | + * |
|
| 61 | + * @since 3.9.0 |
|
| 62 | + * |
|
| 63 | + * @param Wordlift_Configuration_Service $configuration_service A {@link Wordlift_Configuration_Service} instance. |
|
| 64 | + * @param Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 65 | + * @param Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 66 | + */ |
|
| 67 | + public function __construct( $configuration_service, $key_validation_service, $entity_service ) { |
|
| 68 | + |
|
| 69 | + // Set a reference to the configuration service. |
|
| 70 | + $this->configuration_service = $configuration_service; |
|
| 71 | + |
|
| 72 | + // Set a reference to the key validation service. |
|
| 73 | + $this->key_validation_service = $key_validation_service; |
|
| 74 | + |
|
| 75 | + // Set a reference to the entity service. |
|
| 76 | + $this->entity_service = $entity_service; |
|
| 77 | + |
|
| 78 | + // Hook to some WP's events: |
|
| 79 | + // When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up. |
|
| 80 | + add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
| 81 | + |
|
| 82 | + // Hook to `admin_menu` in order to add our own setup wizard page. |
|
| 83 | + add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 84 | + |
|
| 85 | + // Triggered when the user accesses the admin area, we decide whether to show our own wizard. |
|
| 86 | + add_action( 'admin_init', array( $this, 'show_page' ) ); |
|
| 87 | + |
|
| 88 | + // Hook to `admin_notices` to display our notices. |
|
| 89 | + add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 90 | + |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Hook to `admin_init` and redirect to WordLift's setup page if the `_wl_activation_redirect` transient flag is set. |
|
| 95 | + * |
|
| 96 | + * @since 3.9.0 |
|
| 97 | + */ |
|
| 98 | + public function admin_init() { |
|
| 99 | + |
|
| 100 | + // If the `_wl_activation_redirect` is set, the redirect to the setup page. |
|
| 101 | + if ( get_transient( '_wl_activation_redirect' ) ) { |
|
| 102 | + delete_transient( '_wl_activation_redirect' ); |
|
| 103 | + |
|
| 104 | + // If the user asked to skip the wizard then comply. |
|
| 105 | + if ( $this->configuration_service->is_skip_wizard() ) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + // If we're already on the page or the user doesn't have permissions, return. |
|
| 110 | + if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { |
|
| 111 | + return; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + // Finally redirect to the setup page. |
|
| 115 | + wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) ); |
|
| 116 | + |
|
| 117 | + exit; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Generate an admin notice suggesting to start the wizard if there is no configuration. |
|
| 124 | + * |
|
| 125 | + * @since 3.9.0 |
|
| 126 | + */ |
|
| 127 | + public function admin_notices() { |
|
| 128 | + |
|
| 129 | + // Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard. |
|
| 130 | + if ( '' === $this->configuration_service->get_key() && ! $this->configuration_service->is_skip_wizard() ) { ?> |
|
| 131 | 131 | <div id="wl-message" class="updated"> |
| 132 | 132 | <p><?php esc_html_e( 'Welcome to WordLift – You‘re almost ready to start', 'wordlift' ); ?></p> |
| 133 | 133 | <p class="submit"><a href="<?php echo esc_url( admin_url( 'admin.php?page=wl-setup' ) ); ?>" |
@@ -138,129 +138,129 @@ discard block |
||
| 138 | 138 | </div> |
| 139 | 139 | <?php } |
| 140 | 140 | |
| 141 | - } |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - /** |
|
| 144 | - * Handle hiding the wizard notices by user request |
|
| 145 | - * |
|
| 146 | - * @since 3.9.0 |
|
| 147 | - */ |
|
| 148 | - public function hide_notices() { |
|
| 143 | + /** |
|
| 144 | + * Handle hiding the wizard notices by user request |
|
| 145 | + * |
|
| 146 | + * @since 3.9.0 |
|
| 147 | + */ |
|
| 148 | + public function hide_notices() { |
|
| 149 | 149 | |
| 150 | - // If it's not a `wl-hide-notice` or the nonce is not set, return. |
|
| 151 | - if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) { |
|
| 152 | - return; |
|
| 153 | - } |
|
| 150 | + // If it's not a `wl-hide-notice` or the nonce is not set, return. |
|
| 151 | + if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) { |
|
| 152 | + return; |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - // If the nonce is invalid, return an error. |
|
| 156 | - if ( ! wp_verify_nonce( $_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce' ) ) { |
|
| 157 | - wp_die( __( 'Action failed. Please refresh the page and retry.', 'wordlift' ) ); |
|
| 158 | - } |
|
| 155 | + // If the nonce is invalid, return an error. |
|
| 156 | + if ( ! wp_verify_nonce( $_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce' ) ) { |
|
| 157 | + wp_die( __( 'Action failed. Please refresh the page and retry.', 'wordlift' ) ); |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - // If the user doesn't have the right privileges, return an error. |
|
| 161 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 162 | - wp_die( __( 'Cheatin’ huh?', 'wordlift' ) ); |
|
| 163 | - } |
|
| 160 | + // If the user doesn't have the right privileges, return an error. |
|
| 161 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 162 | + wp_die( __( 'Cheatin’ huh?', 'wordlift' ) ); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - // Store a flag telling to skip the wizard. |
|
| 166 | - $this->configuration_service->set_skip_wizard( TRUE ); |
|
| 165 | + // Store a flag telling to skip the wizard. |
|
| 166 | + $this->configuration_service->set_skip_wizard( TRUE ); |
|
| 167 | 167 | |
| 168 | - } |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - /** |
|
| 171 | - * Register the wizard page to be able to access it |
|
| 172 | - * |
|
| 173 | - * @since 3.9.0 |
|
| 174 | - */ |
|
| 175 | - public function admin_menu() { |
|
| 170 | + /** |
|
| 171 | + * Register the wizard page to be able to access it |
|
| 172 | + * |
|
| 173 | + * @since 3.9.0 |
|
| 174 | + */ |
|
| 175 | + public function admin_menu() { |
|
| 176 | 176 | |
| 177 | - // @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu. |
|
| 178 | - add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' ); |
|
| 177 | + // @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu. |
|
| 178 | + add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' ); |
|
| 179 | 179 | |
| 180 | - } |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Displays the wizard page |
|
| 184 | - * |
|
| 185 | - * @since 3.9.0 |
|
| 186 | - */ |
|
| 187 | - public function show_page() { |
|
| 182 | + /** |
|
| 183 | + * Displays the wizard page |
|
| 184 | + * |
|
| 185 | + * @since 3.9.0 |
|
| 186 | + */ |
|
| 187 | + public function show_page() { |
|
| 188 | 188 | |
| 189 | - // First check if we are in the wizard page at all, if not do nothing. |
|
| 190 | - if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) { |
|
| 191 | - return; |
|
| 192 | - } |
|
| 189 | + // First check if we are in the wizard page at all, if not do nothing. |
|
| 190 | + if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) { |
|
| 191 | + return; |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - // If it's a POST and the `wl-save-configuration` action is set, save the configuration. |
|
| 195 | - if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) { |
|
| 194 | + // If it's a POST and the `wl-save-configuration` action is set, save the configuration. |
|
| 195 | + if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) { |
|
| 196 | 196 | |
| 197 | - // Check the nonce and the user capabilities. |
|
| 198 | - check_admin_referer( 'wl-save-configuration' ); |
|
| 197 | + // Check the nonce and the user capabilities. |
|
| 198 | + check_admin_referer( 'wl-save-configuration' ); |
|
| 199 | 199 | |
| 200 | - // Check if the user has the right privileges. |
|
| 201 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 202 | - wp_die( __( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) ); |
|
| 203 | - } |
|
| 200 | + // Check if the user has the right privileges. |
|
| 201 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 202 | + wp_die( __( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) ); |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - // Save the configuration. |
|
| 206 | - $this->save_configuration( $_POST ); |
|
| 205 | + // Save the configuration. |
|
| 206 | + $this->save_configuration( $_POST ); |
|
| 207 | 207 | |
| 208 | - // Redirect to the admin's page. |
|
| 209 | - wp_redirect( admin_url() ); |
|
| 208 | + // Redirect to the admin's page. |
|
| 209 | + wp_redirect( admin_url() ); |
|
| 210 | 210 | |
| 211 | - exit; |
|
| 212 | - } |
|
| 211 | + exit; |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-setup.php'; |
|
| 214 | + include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-setup.php'; |
|
| 215 | 215 | |
| 216 | - exit; |
|
| 217 | - } |
|
| 216 | + exit; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - /** |
|
| 220 | - * Save WordLift's configuration using the provided parameters. |
|
| 221 | - * |
|
| 222 | - * @since 3.9.0 |
|
| 223 | - * |
|
| 224 | - * @param array $params An array of configuration parameters. |
|
| 225 | - */ |
|
| 226 | - private function save_configuration( $params ) { |
|
| 219 | + /** |
|
| 220 | + * Save WordLift's configuration using the provided parameters. |
|
| 221 | + * |
|
| 222 | + * @since 3.9.0 |
|
| 223 | + * |
|
| 224 | + * @param array $params An array of configuration parameters. |
|
| 225 | + */ |
|
| 226 | + private function save_configuration( $params ) { |
|
| 227 | 227 | |
| 228 | - // We have the following parameters: |
|
| 229 | - // `key`, holding WL's key, |
|
| 230 | - // `vocabulary`, holding the vocabulary path, |
|
| 231 | - // `language`, with the language code (e.g. `en`), |
|
| 232 | - // `send_diagnostic`, the user preferences about sharing data with us. |
|
| 233 | - // `user_type`, the user type either `personal` or `company`, |
|
| 234 | - // `name`, with the `personal` or `company`'s name, |
|
| 235 | - // `logo`, the attachment id for the `personal` or `company` entity. |
|
| 228 | + // We have the following parameters: |
|
| 229 | + // `key`, holding WL's key, |
|
| 230 | + // `vocabulary`, holding the vocabulary path, |
|
| 231 | + // `language`, with the language code (e.g. `en`), |
|
| 232 | + // `send_diagnostic`, the user preferences about sharing data with us. |
|
| 233 | + // `user_type`, the user type either `personal` or `company`, |
|
| 234 | + // `name`, with the `personal` or `company`'s name, |
|
| 235 | + // `logo`, the attachment id for the `personal` or `company` entity. |
|
| 236 | 236 | |
| 237 | - // Store the key: |
|
| 238 | - $this->configuration_service->set_key( $params['key'] ); |
|
| 237 | + // Store the key: |
|
| 238 | + $this->configuration_service->set_key( $params['key'] ); |
|
| 239 | 239 | |
| 240 | - // Store the vocabulary path: |
|
| 241 | - $this->configuration_service->set_entity_base_path( $params['vocabulary'] ); |
|
| 240 | + // Store the vocabulary path: |
|
| 241 | + $this->configuration_service->set_entity_base_path( $params['vocabulary'] ); |
|
| 242 | 242 | |
| 243 | - // Store the site's language: |
|
| 244 | - $this->configuration_service->set_language_code( $params['language'] ); |
|
| 243 | + // Store the site's language: |
|
| 244 | + $this->configuration_service->set_language_code( $params['language'] ); |
|
| 245 | 245 | |
| 246 | - // Store the preferences in variable, because if the checkbox is not checked |
|
| 247 | - // the `share-diagnostic` will not exists in `$params` array. |
|
| 248 | - $share_diagnostic_preferences = empty( $params['share-diagnostic'] ) ? 'no' : 'yes' ; |
|
| 246 | + // Store the preferences in variable, because if the checkbox is not checked |
|
| 247 | + // the `share-diagnostic` will not exists in `$params` array. |
|
| 248 | + $share_diagnostic_preferences = empty( $params['share-diagnostic'] ) ? 'no' : 'yes' ; |
|
| 249 | 249 | |
| 250 | - // Store the diagnostic preferences: |
|
| 251 | - $this->configuration_service->set_diagnostic_preferences( $share_diagnostic_preferences ); |
|
| 250 | + // Store the diagnostic preferences: |
|
| 251 | + $this->configuration_service->set_diagnostic_preferences( $share_diagnostic_preferences ); |
|
| 252 | 252 | |
| 253 | - // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
| 254 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' ); |
|
| 253 | + // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
| 254 | + $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' ); |
|
| 255 | 255 | |
| 256 | - // Create an entity for the publisher. |
|
| 257 | - $publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' ); |
|
| 256 | + // Create an entity for the publisher. |
|
| 257 | + $publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' ); |
|
| 258 | 258 | |
| 259 | - // Store the publisher entity post id in the configuration. |
|
| 260 | - $this->configuration_service->set_publisher_id( $publisher_post_id ); |
|
| 259 | + // Store the publisher entity post id in the configuration. |
|
| 260 | + $this->configuration_service->set_publisher_id( $publisher_post_id ); |
|
| 261 | 261 | |
| 262 | - flush_rewrite_rules(); // Needed because of possible change to the entity base path. |
|
| 262 | + flush_rewrite_rules(); // Needed because of possible change to the entity base path. |
|
| 263 | 263 | |
| 264 | - } |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | 266 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * @since 3.9.0 |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
| 65 | 65 | * @param Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
| 66 | 66 | */ |
| 67 | - public function __construct( $configuration_service, $key_validation_service, $entity_service ) { |
|
| 67 | + public function __construct($configuration_service, $key_validation_service, $entity_service) { |
|
| 68 | 68 | |
| 69 | 69 | // Set a reference to the configuration service. |
| 70 | 70 | $this->configuration_service = $configuration_service; |
@@ -77,16 +77,16 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | // Hook to some WP's events: |
| 79 | 79 | // When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up. |
| 80 | - add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
| 80 | + add_action('wp_loaded', array($this, 'hide_notices')); |
|
| 81 | 81 | |
| 82 | 82 | // Hook to `admin_menu` in order to add our own setup wizard page. |
| 83 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 83 | + add_action('admin_menu', array($this, 'admin_menu')); |
|
| 84 | 84 | |
| 85 | 85 | // Triggered when the user accesses the admin area, we decide whether to show our own wizard. |
| 86 | - add_action( 'admin_init', array( $this, 'show_page' ) ); |
|
| 86 | + add_action('admin_init', array($this, 'show_page')); |
|
| 87 | 87 | |
| 88 | 88 | // Hook to `admin_notices` to display our notices. |
| 89 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 89 | + add_action('admin_notices', array($this, 'admin_notices')); |
|
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | |
@@ -98,21 +98,21 @@ discard block |
||
| 98 | 98 | public function admin_init() { |
| 99 | 99 | |
| 100 | 100 | // If the `_wl_activation_redirect` is set, the redirect to the setup page. |
| 101 | - if ( get_transient( '_wl_activation_redirect' ) ) { |
|
| 102 | - delete_transient( '_wl_activation_redirect' ); |
|
| 101 | + if (get_transient('_wl_activation_redirect')) { |
|
| 102 | + delete_transient('_wl_activation_redirect'); |
|
| 103 | 103 | |
| 104 | 104 | // If the user asked to skip the wizard then comply. |
| 105 | - if ( $this->configuration_service->is_skip_wizard() ) { |
|
| 105 | + if ($this->configuration_service->is_skip_wizard()) { |
|
| 106 | 106 | return; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // If we're already on the page or the user doesn't have permissions, return. |
| 110 | - if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { |
|
| 110 | + if (( ! empty($_GET['page']) && 'wl-setup' === $_GET['page']) || is_network_admin() || isset($_GET['activate-multi']) || ! current_user_can('manage_options')) { |
|
| 111 | 111 | return; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | // Finally redirect to the setup page. |
| 115 | - wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) ); |
|
| 115 | + wp_safe_redirect(admin_url('index.php?page=wl-setup')); |
|
| 116 | 116 | |
| 117 | 117 | exit; |
| 118 | 118 | } |
@@ -127,13 +127,13 @@ discard block |
||
| 127 | 127 | public function admin_notices() { |
| 128 | 128 | |
| 129 | 129 | // Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard. |
| 130 | - if ( '' === $this->configuration_service->get_key() && ! $this->configuration_service->is_skip_wizard() ) { ?> |
|
| 130 | + if ('' === $this->configuration_service->get_key() && ! $this->configuration_service->is_skip_wizard()) { ?> |
|
| 131 | 131 | <div id="wl-message" class="updated"> |
| 132 | - <p><?php esc_html_e( 'Welcome to WordLift – You‘re almost ready to start', 'wordlift' ); ?></p> |
|
| 133 | - <p class="submit"><a href="<?php echo esc_url( admin_url( 'admin.php?page=wl-setup' ) ); ?>" |
|
| 134 | - class="button-primary"><?php esc_html_e( 'Run the Setup Wizard', 'wordlift' ); ?></a> |
|
| 132 | + <p><?php esc_html_e('Welcome to WordLift – You‘re almost ready to start', 'wordlift'); ?></p> |
|
| 133 | + <p class="submit"><a href="<?php echo esc_url(admin_url('admin.php?page=wl-setup')); ?>" |
|
| 134 | + class="button-primary"><?php esc_html_e('Run the Setup Wizard', 'wordlift'); ?></a> |
|
| 135 | 135 | <a class="button-secondary skip" |
| 136 | - href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wl-hide-notice', 'install' ), 'wordlift_hide_notices_nonce', '_wl_notice_nonce' ) ); ?>"><?php esc_html_e( 'Skip Setup', 'wordlift' ); ?></a> |
|
| 136 | + href="<?php echo esc_url(wp_nonce_url(add_query_arg('wl-hide-notice', 'install'), 'wordlift_hide_notices_nonce', '_wl_notice_nonce')); ?>"><?php esc_html_e('Skip Setup', 'wordlift'); ?></a> |
|
| 137 | 137 | </p> |
| 138 | 138 | </div> |
| 139 | 139 | <?php } |
@@ -148,22 +148,22 @@ discard block |
||
| 148 | 148 | public function hide_notices() { |
| 149 | 149 | |
| 150 | 150 | // If it's not a `wl-hide-notice` or the nonce is not set, return. |
| 151 | - if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) { |
|
| 151 | + if ( ! isset($_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'])) { |
|
| 152 | 152 | return; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // If the nonce is invalid, return an error. |
| 156 | - if ( ! wp_verify_nonce( $_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce' ) ) { |
|
| 157 | - wp_die( __( 'Action failed. Please refresh the page and retry.', 'wordlift' ) ); |
|
| 156 | + if ( ! wp_verify_nonce($_GET['_wl_notice_nonce'], 'wordlift_hide_notices_nonce')) { |
|
| 157 | + wp_die(__('Action failed. Please refresh the page and retry.', 'wordlift')); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // If the user doesn't have the right privileges, return an error. |
| 161 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 162 | - wp_die( __( 'Cheatin’ huh?', 'wordlift' ) ); |
|
| 161 | + if ( ! current_user_can('manage_options')) { |
|
| 162 | + wp_die(__('Cheatin’ huh?', 'wordlift')); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Store a flag telling to skip the wizard. |
| 166 | - $this->configuration_service->set_skip_wizard( TRUE ); |
|
| 166 | + $this->configuration_service->set_skip_wizard(TRUE); |
|
| 167 | 167 | |
| 168 | 168 | } |
| 169 | 169 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | public function admin_menu() { |
| 176 | 176 | |
| 177 | 177 | // @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu. |
| 178 | - add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' ); |
|
| 178 | + add_dashboard_page('', '', 'manage_options', 'wl-setup', ''); |
|
| 179 | 179 | |
| 180 | 180 | } |
| 181 | 181 | |
@@ -187,31 +187,31 @@ discard block |
||
| 187 | 187 | public function show_page() { |
| 188 | 188 | |
| 189 | 189 | // First check if we are in the wizard page at all, if not do nothing. |
| 190 | - if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) { |
|
| 190 | + if (empty($_GET['page']) || 'wl-setup' !== $_GET['page']) { |
|
| 191 | 191 | return; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | // If it's a POST and the `wl-save-configuration` action is set, save the configuration. |
| 195 | - if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) { |
|
| 195 | + if (isset($_POST['action']) && 'wl-save-configuration' === $_POST['action']) { |
|
| 196 | 196 | |
| 197 | 197 | // Check the nonce and the user capabilities. |
| 198 | - check_admin_referer( 'wl-save-configuration' ); |
|
| 198 | + check_admin_referer('wl-save-configuration'); |
|
| 199 | 199 | |
| 200 | 200 | // Check if the user has the right privileges. |
| 201 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 202 | - wp_die( __( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) ); |
|
| 201 | + if ( ! current_user_can('manage_options')) { |
|
| 202 | + wp_die(__('Sorry, you do not have a permission to save the settings', 'wordlift')); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // Save the configuration. |
| 206 | - $this->save_configuration( $_POST ); |
|
| 206 | + $this->save_configuration($_POST); |
|
| 207 | 207 | |
| 208 | 208 | // Redirect to the admin's page. |
| 209 | - wp_redirect( admin_url() ); |
|
| 209 | + wp_redirect(admin_url()); |
|
| 210 | 210 | |
| 211 | 211 | exit; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - include plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/wordlift-admin-setup.php'; |
|
| 214 | + include plugin_dir_path(dirname(__FILE__)).'admin/partials/wordlift-admin-setup.php'; |
|
| 215 | 215 | |
| 216 | 216 | exit; |
| 217 | 217 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * |
| 224 | 224 | * @param array $params An array of configuration parameters. |
| 225 | 225 | */ |
| 226 | - private function save_configuration( $params ) { |
|
| 226 | + private function save_configuration($params) { |
|
| 227 | 227 | |
| 228 | 228 | // We have the following parameters: |
| 229 | 229 | // `key`, holding WL's key, |
@@ -235,29 +235,29 @@ discard block |
||
| 235 | 235 | // `logo`, the attachment id for the `personal` or `company` entity. |
| 236 | 236 | |
| 237 | 237 | // Store the key: |
| 238 | - $this->configuration_service->set_key( $params['key'] ); |
|
| 238 | + $this->configuration_service->set_key($params['key']); |
|
| 239 | 239 | |
| 240 | 240 | // Store the vocabulary path: |
| 241 | - $this->configuration_service->set_entity_base_path( $params['vocabulary'] ); |
|
| 241 | + $this->configuration_service->set_entity_base_path($params['vocabulary']); |
|
| 242 | 242 | |
| 243 | 243 | // Store the site's language: |
| 244 | - $this->configuration_service->set_language_code( $params['language'] ); |
|
| 244 | + $this->configuration_service->set_language_code($params['language']); |
|
| 245 | 245 | |
| 246 | 246 | // Store the preferences in variable, because if the checkbox is not checked |
| 247 | 247 | // the `share-diagnostic` will not exists in `$params` array. |
| 248 | - $share_diagnostic_preferences = empty( $params['share-diagnostic'] ) ? 'no' : 'yes' ; |
|
| 248 | + $share_diagnostic_preferences = empty($params['share-diagnostic']) ? 'no' : 'yes'; |
|
| 249 | 249 | |
| 250 | 250 | // Store the diagnostic preferences: |
| 251 | - $this->configuration_service->set_diagnostic_preferences( $share_diagnostic_preferences ); |
|
| 251 | + $this->configuration_service->set_diagnostic_preferences($share_diagnostic_preferences); |
|
| 252 | 252 | |
| 253 | 253 | // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
| 254 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' ); |
|
| 254 | + $type_uri = sprintf('http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person'); |
|
| 255 | 255 | |
| 256 | 256 | // Create an entity for the publisher. |
| 257 | - $publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' ); |
|
| 257 | + $publisher_post_id = $this->entity_service->create($params['name'], $type_uri, $params['logo'], 'publish'); |
|
| 258 | 258 | |
| 259 | 259 | // Store the publisher entity post id in the configuration. |
| 260 | - $this->configuration_service->set_publisher_id( $publisher_post_id ); |
|
| 260 | + $this->configuration_service->set_publisher_id($publisher_post_id); |
|
| 261 | 261 | |
| 262 | 262 | flush_rewrite_rules(); // Needed because of possible change to the entity base path. |
| 263 | 263 | |
@@ -1,16 +1,16 @@ |
||
| 1 | 1 | <?php $articles = $this->get_last_wordlift_articles(); ?> |
| 2 | 2 | <div id='news_container'> |
| 3 | - <?php if ( ! empty( $articles['posts_data'] ) ) { ?> |
|
| 4 | - <?php foreach ( $articles['posts_data'] as $key => $item ) { ?> |
|
| 3 | + <?php if ( ! empty($articles['posts_data'])) { ?> |
|
| 4 | + <?php foreach ($articles['posts_data'] as $key => $item) { ?> |
|
| 5 | 5 | <div> |
| 6 | 6 | <a target="_blank" |
| 7 | - href="<?php echo esc_url( $item['post_url'] ); ?>"><?php echo esc_html( $item['post_title'] ); ?></a> |
|
| 7 | + href="<?php echo esc_url($item['post_url']); ?>"><?php echo esc_html($item['post_title']); ?></a> |
|
| 8 | 8 | <p><?php echo $item['post_description']; ?></p> |
| 9 | 9 | </div> |
| 10 | 10 | <?php } ?> |
| 11 | 11 | <?php } ?> |
| 12 | 12 | <div> |
| 13 | 13 | <a href="#" id="max_posts_count_3" |
| 14 | - class="wl_more_posts"><?php echo esc_html__( 'More posts', 'wordlift' ); ?></a> |
|
| 14 | + class="wl_more_posts"><?php echo esc_html__('More posts', 'wordlift'); ?></a> |
|
| 15 | 15 | </div> |
| 16 | 16 | </div> |
@@ -1,42 +1,42 @@ discard block |
||
| 1 | 1 | <!-- Pane 1 content --> |
| 2 | 2 | <script type="text/html" id="page-0"> |
| 3 | 3 | <h2 class="page-title"> |
| 4 | - <?php esc_html_e( 'Welcome', 'wordlift' ); ?> |
|
| 4 | + <?php esc_html_e('Welcome', 'wordlift'); ?> |
|
| 5 | 5 | </h2> |
| 6 | 6 | |
| 7 | 7 | <p class="page-txt"> |
| 8 | - <?php esc_html_e( 'Thank you for downloading WordLift. Now you can boost your website with a double-digit growth. WordLift helps you with:', 'wordlift' ); ?> |
|
| 8 | + <?php esc_html_e('Thank you for downloading WordLift. Now you can boost your website with a double-digit growth. WordLift helps you with:', 'wordlift'); ?> |
|
| 9 | 9 | </p> |
| 10 | 10 | |
| 11 | 11 | <ul class="page-list"> |
| 12 | 12 | <li> |
| 13 | 13 | <span class="fa fa-university"></span> |
| 14 | - <?php esc_html_e( 'Trustworthiness', 'wordlift' ); ?> |
|
| 14 | + <?php esc_html_e('Trustworthiness', 'wordlift'); ?> |
|
| 15 | 15 | </li> |
| 16 | 16 | |
| 17 | 17 | <li> |
| 18 | 18 | <span class="fa fa-map-marker"></span> |
| 19 | - <?php esc_html_e( 'Enrichment', 'wordlift' ); ?> |
|
| 19 | + <?php esc_html_e('Enrichment', 'wordlift'); ?> |
|
| 20 | 20 | </li> |
| 21 | 21 | |
| 22 | 22 | <li> |
| 23 | 23 | <span class="fa fa-heart"></span> |
| 24 | - <?php esc_html_e( 'Engagement', 'wordlift' ); ?> |
|
| 24 | + <?php esc_html_e('Engagement', 'wordlift'); ?> |
|
| 25 | 25 | </li> |
| 26 | 26 | |
| 27 | 27 | <li> |
| 28 | 28 | <span class="fa fa-hand-o-right"></span> |
| 29 | - <?php esc_html_e( 'Smart Navigation', 'wordlift' ); ?> |
|
| 29 | + <?php esc_html_e('Smart Navigation', 'wordlift'); ?> |
|
| 30 | 30 | </li> |
| 31 | 31 | |
| 32 | 32 | <li> |
| 33 | 33 | <span class="fa fa-google"></span> |
| 34 | - <?php esc_html_e( 'SEO Optimization', 'wordlift' ); ?> |
|
| 34 | + <?php esc_html_e('SEO Optimization', 'wordlift'); ?> |
|
| 35 | 35 | </li> |
| 36 | 36 | |
| 37 | 37 | <li> |
| 38 | 38 | <span class="fa fa-group"></span> |
| 39 | - <?php esc_html_e( 'Content Marketing', 'wordlift' ); ?> |
|
| 39 | + <?php esc_html_e('Content Marketing', 'wordlift'); ?> |
|
| 40 | 40 | </li> |
| 41 | 41 | </ul> |
| 42 | 42 | |
@@ -46,13 +46,13 @@ discard block |
||
| 46 | 46 | target="_tab" |
| 47 | 47 | class="button" |
| 48 | 48 | > |
| 49 | - <?php esc_html_e( 'Learn More', 'wordlift' ); ?> |
|
| 49 | + <?php esc_html_e('Learn More', 'wordlift'); ?> |
|
| 50 | 50 | </a> |
| 51 | 51 | <input |
| 52 | 52 | type="button" |
| 53 | 53 | data-wl-next="wl-next" |
| 54 | 54 | class="wl-default-action" |
| 55 | - value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>" |
|
| 55 | + value="<?php esc_attr_e('Next', 'wordlift'); ?>" |
|
| 56 | 56 | > |
| 57 | 57 | </div> |
| 58 | 58 | </script> |
| 59 | 59 | \ No newline at end of file |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <!-- Pane 4 content --> |
| 2 | 2 | <script type="text/html" id="page-3"> |
| 3 | 3 | <h2 class="page-title"> |
| 4 | - <?php esc_html_e( 'Vocabulary', 'wordlift' ); ?> |
|
| 4 | + <?php esc_html_e('Vocabulary', 'wordlift'); ?> |
|
| 5 | 5 | </h2> |
| 6 | 6 | |
| 7 | 7 | <p class="page-txt"> |
| 8 | - <?php esc_html_e( 'All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field below. Check our FAQs if you need more info.', 'wordlift' ); ?> |
|
| 8 | + <?php esc_html_e('All new pages created with WordLift, will be stored inside your internal vocabulary. You can customize the url pattern of these pages in the field below. Check our FAQs if you need more info.', 'wordlift'); ?> |
|
| 9 | 9 | </p> |
| 10 | 10 | |
| 11 | 11 | <input |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | > |
| 20 | 20 | |
| 21 | 21 | <p class="page-det"> |
| 22 | - <?php esc_html_e( 'Leave it empty to place your entities in the root folder of your website', 'wordlift' ); ?> |
|
| 22 | + <?php esc_html_e('Leave it empty to place your entities in the root folder of your website', 'wordlift'); ?> |
|
| 23 | 23 | </p> |
| 24 | 24 | |
| 25 | 25 | <div class="btn-wrapper"> |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | type="button" |
| 28 | 28 | data-wl-next="wl-next" |
| 29 | 29 | class="wl-default-action" |
| 30 | - value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>" |
|
| 30 | + value="<?php esc_attr_e('Next', 'wordlift'); ?>" |
|
| 31 | 31 | > |
| 32 | 32 | </div> |
| 33 | 33 | </script> |
@@ -6,8 +6,8 @@ |
||
| 6 | 6 | <br> |
| 7 | 7 | <p class="page-txt"> |
| 8 | 8 | <?php |
| 9 | - esc_html_e( 'Help us improve our product by automatically sending diagnostic and usage data.', 'wordlift' ); |
|
| 10 | - ?> |
|
| 9 | + esc_html_e( 'Help us improve our product by automatically sending diagnostic and usage data.', 'wordlift' ); |
|
| 10 | + ?> |
|
| 11 | 11 | </p> |
| 12 | 12 | <input |
| 13 | 13 | type="checkbox" |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <!-- Pane 2 content --> |
| 2 | 2 | <script type="text/html" id="page-1"> |
| 3 | 3 | <h2 class="page-title"> |
| 4 | - <?php esc_html_e( 'Diagnostic', 'wordlift' ); ?> |
|
| 4 | + <?php esc_html_e('Diagnostic', 'wordlift'); ?> |
|
| 5 | 5 | </h2> |
| 6 | 6 | <br> |
| 7 | 7 | <p class="page-txt"> |
| 8 | 8 | <?php |
| 9 | - esc_html_e( 'Help us improve our product by automatically sending diagnostic and usage data.', 'wordlift' ); |
|
| 9 | + esc_html_e('Help us improve our product by automatically sending diagnostic and usage data.', 'wordlift'); |
|
| 10 | 10 | ?> |
| 11 | 11 | </p> |
| 12 | 12 | <input |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | checked |
| 18 | 18 | > |
| 19 | 19 | <label for="share-diagnostic"> |
| 20 | - <?php esc_html_e( 'Share diagnostic data', 'wordlift' ); ?> |
|
| 20 | + <?php esc_html_e('Share diagnostic data', 'wordlift'); ?> |
|
| 21 | 21 | </label> |
| 22 | 22 | |
| 23 | 23 | <p class="privacy-policy-details"> |
| 24 | 24 | <a href="https://wordlift.io/privacy-policy/" target="_blank"> |
| 25 | - <?php esc_html_e( 'About our privacy policy...', 'wordlift' ); ?> |
|
| 25 | + <?php esc_html_e('About our privacy policy...', 'wordlift'); ?> |
|
| 26 | 26 | </a> |
| 27 | 27 | </p> |
| 28 | 28 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | type="button" |
| 32 | 32 | data-wl-next="wl-next" |
| 33 | 33 | class="wl-default-action" |
| 34 | - value="<?php esc_attr_e( 'Next', 'wordlift' ); ?>" |
|
| 34 | + value="<?php esc_attr_e('Next', 'wordlift'); ?>" |
|
| 35 | 35 | > |
| 36 | 36 | </div> |
| 37 | 37 | </script> |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <!-- Pane 6 content --> |
| 2 | 2 | <script type="text/html" id="page-5"> |
| 3 | 3 | <h2 class="page-title"> |
| 4 | - <?php esc_html_e( 'Publisher', 'wordlift' ); ?> |
|
| 4 | + <?php esc_html_e('Publisher', 'wordlift'); ?> |
|
| 5 | 5 | </h2> |
| 6 | 6 | |
| 7 | 7 | <p class="page-txt"> |
| 8 | - <?php esc_html_e( 'Are you going to publish as an individual or as a company?', 'wordlift' ); ?> |
|
| 8 | + <?php esc_html_e('Are you going to publish as an individual or as a company?', 'wordlift'); ?> |
|
| 9 | 9 | </p> |
| 10 | 10 | |
| 11 | 11 | <div class="radio-wrapper"> |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | <span class="radio"><span class="check"></span></span> |
| 21 | 21 | |
| 22 | 22 | <span class="label"> |
| 23 | - <?php esc_html_e( 'Personal', 'wordlift' ); ?> |
|
| 23 | + <?php esc_html_e('Personal', 'wordlift'); ?> |
|
| 24 | 24 | </span> |
| 25 | 25 | </label> |
| 26 | 26 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | <span class="radio"><span class="check"></span></span> |
| 36 | 36 | |
| 37 | 37 | <span class="label"> |
| 38 | - <?php esc_html_e( 'Company', 'wordlift' ); ?> |
|
| 38 | + <?php esc_html_e('Company', 'wordlift'); ?> |
|
| 39 | 39 | </span> |
| 40 | 40 | </label> |
| 41 | 41 | </div> |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | value="" |
| 48 | 48 | autocomplete="off" |
| 49 | 49 | class="untouched invalid" |
| 50 | - placeholder="<?php esc_attr_e( "What's your name?", 'wordlift' ); ?>" |
|
| 50 | + placeholder="<?php esc_attr_e("What's your name?", 'wordlift'); ?>" |
|
| 51 | 51 | > |
| 52 | 52 | |
| 53 | 53 | <div data-wl-logo="wl-logo"> |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | class="add-logo" |
| 66 | 66 | href="javascript:void(0);" |
| 67 | 67 | > |
| 68 | - <?php esc_html_e( 'Add your logo', 'wordlift' ); ?> |
|
| 68 | + <?php esc_html_e('Add your logo', 'wordlift'); ?> |
|
| 69 | 69 | </a> |
| 70 | 70 | </div> |
| 71 | 71 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | type="submit" |
| 75 | 75 | id="btn-finish" |
| 76 | 76 | class="wl-default-action" |
| 77 | - value="<?php esc_attr_e( 'Finish', 'wordlift' ); ?>" |
|
| 77 | + value="<?php esc_attr_e('Finish', 'wordlift'); ?>" |
|
| 78 | 78 | > |
| 79 | 79 | </div> |
| 80 | 80 | </script> |