@@ -19,125 +19,125 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Wordlift_Admin_Author_Element implements Wordlift_Admin_Element { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * The {@link Wordlift_Publisher_Service} instance. |
|
| 24 | - * |
|
| 25 | - * @since 3.14.0 |
|
| 26 | - * @access private |
|
| 27 | - * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 28 | - */ |
|
| 29 | - private $publisher_service; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * A {@link Wordlift_Admin_Select2_Element} instance. |
|
| 33 | - * |
|
| 34 | - * @since 3.14.0 |
|
| 35 | - * @access private |
|
| 36 | - * @var \Wordlift_Admin_Select2_Element $select_element A {@link Wordlift_Admin_Select2_Element} instance. |
|
| 37 | - */ |
|
| 38 | - private $select_element; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Create a {@link Wordlift_Admin_Person_Element} instance. |
|
| 42 | - * |
|
| 43 | - * @param \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 44 | - * @param \Wordlift_Admin_Select2_Element $select_element The {@link Wordlift_Admin_Select_Element} instance. |
|
| 45 | - * |
|
| 46 | - * @since 3.14.0 |
|
| 47 | - */ |
|
| 48 | - public function __construct( $publisher_service, $select_element ) { |
|
| 49 | - |
|
| 50 | - $this->publisher_service = $publisher_service; |
|
| 51 | - |
|
| 52 | - // Child elements. |
|
| 53 | - $this->select_element = $select_element; |
|
| 54 | - |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @inheritdoc |
|
| 59 | - */ |
|
| 60 | - public function render( $args ) { |
|
| 61 | - |
|
| 62 | - // Parse the arguments and merge with default values. |
|
| 63 | - $params = wp_parse_args( |
|
| 64 | - $args, |
|
| 65 | - array( |
|
| 66 | - 'id' => uniqid( 'wl-input-' ), |
|
| 67 | - 'name' => uniqid( 'wl-input-' ), |
|
| 68 | - 'current_entity' => 0, |
|
| 69 | - ) |
|
| 70 | - ); |
|
| 71 | - |
|
| 72 | - $current_entity_id = $params['current_entity']; |
|
| 73 | - $data = $this->publisher_service->query(); |
|
| 74 | - |
|
| 75 | - // Set a default to show when no entity is associated and a way to unassign. |
|
| 76 | - array_unshift( |
|
| 77 | - $data, |
|
| 78 | - array( |
|
| 79 | - 'id' => '0', |
|
| 80 | - 'text' => '<em>' . __( '(none)', 'wordlift' ) . '</em>', |
|
| 81 | - 'type' => '', |
|
| 82 | - 'thumbnail_url' => plugin_dir_url( __DIR__ ) . 'images/pixel.png', |
|
| 83 | - ) |
|
| 84 | - ); |
|
| 85 | - |
|
| 86 | - // Finally do the render, passing along also the current selected entity |
|
| 87 | - // id and the options data. |
|
| 88 | - return $this->do_render( $params, $current_entity_id, $data ); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * Render the `select` using the provided parameters. |
|
| 93 | - * |
|
| 94 | - * @param array $params The array of parameters from the `render` function. |
|
| 95 | - * @param int $current_post_id The currently selected {@link WP_Post} `id`. |
|
| 96 | - * @param array $data An array of Select2 options. |
|
| 97 | - * |
|
| 98 | - * @return \Wordlift_Admin_Author_Element $this Return this element. |
|
| 99 | - * @since 3.14.0 |
|
| 100 | - */ |
|
| 101 | - protected function do_render( $params, $current_post_id, $data ) { |
|
| 102 | - |
|
| 103 | - // Queue the script which will initialize the select and style it. |
|
| 104 | - wp_enqueue_script( 'wl-author-element', plugin_dir_url( __DIR__ ) . 'js/1/author.js', array( 'wordlift-select2' ), WORDLIFT_VERSION, false ); |
|
| 105 | - wp_enqueue_style( 'wl-author-element', plugin_dir_url( __DIR__ ) . 'js/1/author.css', array(), WORDLIFT_VERSION ); |
|
| 106 | - |
|
| 107 | - // Prepare the URLs for entities which don't have logos. |
|
| 108 | - $person_thumbnail_url = plugin_dir_url( __DIR__ ) . '../images/person.png'; |
|
| 109 | - $organization_thumbnail_url = plugin_dir_url( __DIR__ ) . '../images/organization.png'; |
|
| 110 | - |
|
| 111 | - // Get the current post. |
|
| 112 | - $current_post = $current_post_id ? get_post( $current_post_id ) : null; |
|
| 113 | - |
|
| 114 | - // Finally render the Select. |
|
| 115 | - $this->select_element->render( |
|
| 116 | - array( |
|
| 117 | - // Id. |
|
| 118 | - 'id' => $params['id'], |
|
| 119 | - // Name. |
|
| 120 | - 'name' => $params['name'], |
|
| 121 | - // Class names. |
|
| 122 | - 'class' => 'wl-select2-element', |
|
| 123 | - // The selected id. |
|
| 124 | - 'value' => $current_post_id, |
|
| 125 | - // The selected item (must be in the options for Select2 to display it). |
|
| 126 | - 'options' => $current_post ? array( $current_post->ID => $current_post->post_title ) : array(), |
|
| 127 | - // Data attributes. |
|
| 128 | - 'data' => array( |
|
| 129 | - // The list of available options. |
|
| 130 | - 'wl-select2-data' => wp_json_encode( $data ), |
|
| 131 | - // The HTML template for each option. |
|
| 132 | - 'wl-select2-template-result' => "<div class='wl-select2-result'><span class='wl-select2-thumbnail' style='background-image: url( <%- obj.thumbnail_url || ( 'Organization' === obj.type ? '$organization_thumbnail_url' : '$person_thumbnail_url' ) %> );'> </span><span class='wl-select2'><%- obj.text %></span><span class='wl-select2-type'><%- obj.type %></span></div>", |
|
| 133 | - // The HTML template for the selected option. |
|
| 134 | - 'wl-select2-template-selection' => "<div class='wl-select2-selection'><span class='wl-select2-thumbnail' style='background-image: url( <%- obj.thumbnail_url || ( 'Organization' === obj.type ? '$organization_thumbnail_url' : '$person_thumbnail_url' ) %> );'> </span><span class='wl-select2'><%- obj.text %></span><span class='wl-select2-type'><%- obj.type %></span></div>", |
|
| 135 | - ), |
|
| 136 | - ) |
|
| 137 | - ); |
|
| 138 | - |
|
| 139 | - // Finally return the element instance. |
|
| 140 | - return $this; |
|
| 141 | - } |
|
| 22 | + /** |
|
| 23 | + * The {@link Wordlift_Publisher_Service} instance. |
|
| 24 | + * |
|
| 25 | + * @since 3.14.0 |
|
| 26 | + * @access private |
|
| 27 | + * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 28 | + */ |
|
| 29 | + private $publisher_service; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * A {@link Wordlift_Admin_Select2_Element} instance. |
|
| 33 | + * |
|
| 34 | + * @since 3.14.0 |
|
| 35 | + * @access private |
|
| 36 | + * @var \Wordlift_Admin_Select2_Element $select_element A {@link Wordlift_Admin_Select2_Element} instance. |
|
| 37 | + */ |
|
| 38 | + private $select_element; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Create a {@link Wordlift_Admin_Person_Element} instance. |
|
| 42 | + * |
|
| 43 | + * @param \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 44 | + * @param \Wordlift_Admin_Select2_Element $select_element The {@link Wordlift_Admin_Select_Element} instance. |
|
| 45 | + * |
|
| 46 | + * @since 3.14.0 |
|
| 47 | + */ |
|
| 48 | + public function __construct( $publisher_service, $select_element ) { |
|
| 49 | + |
|
| 50 | + $this->publisher_service = $publisher_service; |
|
| 51 | + |
|
| 52 | + // Child elements. |
|
| 53 | + $this->select_element = $select_element; |
|
| 54 | + |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @inheritdoc |
|
| 59 | + */ |
|
| 60 | + public function render( $args ) { |
|
| 61 | + |
|
| 62 | + // Parse the arguments and merge with default values. |
|
| 63 | + $params = wp_parse_args( |
|
| 64 | + $args, |
|
| 65 | + array( |
|
| 66 | + 'id' => uniqid( 'wl-input-' ), |
|
| 67 | + 'name' => uniqid( 'wl-input-' ), |
|
| 68 | + 'current_entity' => 0, |
|
| 69 | + ) |
|
| 70 | + ); |
|
| 71 | + |
|
| 72 | + $current_entity_id = $params['current_entity']; |
|
| 73 | + $data = $this->publisher_service->query(); |
|
| 74 | + |
|
| 75 | + // Set a default to show when no entity is associated and a way to unassign. |
|
| 76 | + array_unshift( |
|
| 77 | + $data, |
|
| 78 | + array( |
|
| 79 | + 'id' => '0', |
|
| 80 | + 'text' => '<em>' . __( '(none)', 'wordlift' ) . '</em>', |
|
| 81 | + 'type' => '', |
|
| 82 | + 'thumbnail_url' => plugin_dir_url( __DIR__ ) . 'images/pixel.png', |
|
| 83 | + ) |
|
| 84 | + ); |
|
| 85 | + |
|
| 86 | + // Finally do the render, passing along also the current selected entity |
|
| 87 | + // id and the options data. |
|
| 88 | + return $this->do_render( $params, $current_entity_id, $data ); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * Render the `select` using the provided parameters. |
|
| 93 | + * |
|
| 94 | + * @param array $params The array of parameters from the `render` function. |
|
| 95 | + * @param int $current_post_id The currently selected {@link WP_Post} `id`. |
|
| 96 | + * @param array $data An array of Select2 options. |
|
| 97 | + * |
|
| 98 | + * @return \Wordlift_Admin_Author_Element $this Return this element. |
|
| 99 | + * @since 3.14.0 |
|
| 100 | + */ |
|
| 101 | + protected function do_render( $params, $current_post_id, $data ) { |
|
| 102 | + |
|
| 103 | + // Queue the script which will initialize the select and style it. |
|
| 104 | + wp_enqueue_script( 'wl-author-element', plugin_dir_url( __DIR__ ) . 'js/1/author.js', array( 'wordlift-select2' ), WORDLIFT_VERSION, false ); |
|
| 105 | + wp_enqueue_style( 'wl-author-element', plugin_dir_url( __DIR__ ) . 'js/1/author.css', array(), WORDLIFT_VERSION ); |
|
| 106 | + |
|
| 107 | + // Prepare the URLs for entities which don't have logos. |
|
| 108 | + $person_thumbnail_url = plugin_dir_url( __DIR__ ) . '../images/person.png'; |
|
| 109 | + $organization_thumbnail_url = plugin_dir_url( __DIR__ ) . '../images/organization.png'; |
|
| 110 | + |
|
| 111 | + // Get the current post. |
|
| 112 | + $current_post = $current_post_id ? get_post( $current_post_id ) : null; |
|
| 113 | + |
|
| 114 | + // Finally render the Select. |
|
| 115 | + $this->select_element->render( |
|
| 116 | + array( |
|
| 117 | + // Id. |
|
| 118 | + 'id' => $params['id'], |
|
| 119 | + // Name. |
|
| 120 | + 'name' => $params['name'], |
|
| 121 | + // Class names. |
|
| 122 | + 'class' => 'wl-select2-element', |
|
| 123 | + // The selected id. |
|
| 124 | + 'value' => $current_post_id, |
|
| 125 | + // The selected item (must be in the options for Select2 to display it). |
|
| 126 | + 'options' => $current_post ? array( $current_post->ID => $current_post->post_title ) : array(), |
|
| 127 | + // Data attributes. |
|
| 128 | + 'data' => array( |
|
| 129 | + // The list of available options. |
|
| 130 | + 'wl-select2-data' => wp_json_encode( $data ), |
|
| 131 | + // The HTML template for each option. |
|
| 132 | + 'wl-select2-template-result' => "<div class='wl-select2-result'><span class='wl-select2-thumbnail' style='background-image: url( <%- obj.thumbnail_url || ( 'Organization' === obj.type ? '$organization_thumbnail_url' : '$person_thumbnail_url' ) %> );'> </span><span class='wl-select2'><%- obj.text %></span><span class='wl-select2-type'><%- obj.type %></span></div>", |
|
| 133 | + // The HTML template for the selected option. |
|
| 134 | + 'wl-select2-template-selection' => "<div class='wl-select2-selection'><span class='wl-select2-thumbnail' style='background-image: url( <%- obj.thumbnail_url || ( 'Organization' === obj.type ? '$organization_thumbnail_url' : '$person_thumbnail_url' ) %> );'> </span><span class='wl-select2'><%- obj.text %></span><span class='wl-select2-type'><%- obj.type %></span></div>", |
|
| 135 | + ), |
|
| 136 | + ) |
|
| 137 | + ); |
|
| 138 | + |
|
| 139 | + // Finally return the element instance. |
|
| 140 | + return $this; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | 143 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @since 3.14.0 |
| 47 | 47 | */ |
| 48 | - public function __construct( $publisher_service, $select_element ) { |
|
| 48 | + public function __construct($publisher_service, $select_element) { |
|
| 49 | 49 | |
| 50 | 50 | $this->publisher_service = $publisher_service; |
| 51 | 51 | |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | /** |
| 58 | 58 | * @inheritdoc |
| 59 | 59 | */ |
| 60 | - public function render( $args ) { |
|
| 60 | + public function render($args) { |
|
| 61 | 61 | |
| 62 | 62 | // Parse the arguments and merge with default values. |
| 63 | 63 | $params = wp_parse_args( |
| 64 | 64 | $args, |
| 65 | 65 | array( |
| 66 | - 'id' => uniqid( 'wl-input-' ), |
|
| 67 | - 'name' => uniqid( 'wl-input-' ), |
|
| 66 | + 'id' => uniqid('wl-input-'), |
|
| 67 | + 'name' => uniqid('wl-input-'), |
|
| 68 | 68 | 'current_entity' => 0, |
| 69 | 69 | ) |
| 70 | 70 | ); |
@@ -77,15 +77,15 @@ discard block |
||
| 77 | 77 | $data, |
| 78 | 78 | array( |
| 79 | 79 | 'id' => '0', |
| 80 | - 'text' => '<em>' . __( '(none)', 'wordlift' ) . '</em>', |
|
| 80 | + 'text' => '<em>'.__('(none)', 'wordlift').'</em>', |
|
| 81 | 81 | 'type' => '', |
| 82 | - 'thumbnail_url' => plugin_dir_url( __DIR__ ) . 'images/pixel.png', |
|
| 82 | + 'thumbnail_url' => plugin_dir_url(__DIR__).'images/pixel.png', |
|
| 83 | 83 | ) |
| 84 | 84 | ); |
| 85 | 85 | |
| 86 | 86 | // Finally do the render, passing along also the current selected entity |
| 87 | 87 | // id and the options data. |
| 88 | - return $this->do_render( $params, $current_entity_id, $data ); |
|
| 88 | + return $this->do_render($params, $current_entity_id, $data); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -98,18 +98,18 @@ discard block |
||
| 98 | 98 | * @return \Wordlift_Admin_Author_Element $this Return this element. |
| 99 | 99 | * @since 3.14.0 |
| 100 | 100 | */ |
| 101 | - protected function do_render( $params, $current_post_id, $data ) { |
|
| 101 | + protected function do_render($params, $current_post_id, $data) { |
|
| 102 | 102 | |
| 103 | 103 | // Queue the script which will initialize the select and style it. |
| 104 | - wp_enqueue_script( 'wl-author-element', plugin_dir_url( __DIR__ ) . 'js/1/author.js', array( 'wordlift-select2' ), WORDLIFT_VERSION, false ); |
|
| 105 | - wp_enqueue_style( 'wl-author-element', plugin_dir_url( __DIR__ ) . 'js/1/author.css', array(), WORDLIFT_VERSION ); |
|
| 104 | + wp_enqueue_script('wl-author-element', plugin_dir_url(__DIR__).'js/1/author.js', array('wordlift-select2'), WORDLIFT_VERSION, false); |
|
| 105 | + wp_enqueue_style('wl-author-element', plugin_dir_url(__DIR__).'js/1/author.css', array(), WORDLIFT_VERSION); |
|
| 106 | 106 | |
| 107 | 107 | // Prepare the URLs for entities which don't have logos. |
| 108 | - $person_thumbnail_url = plugin_dir_url( __DIR__ ) . '../images/person.png'; |
|
| 109 | - $organization_thumbnail_url = plugin_dir_url( __DIR__ ) . '../images/organization.png'; |
|
| 108 | + $person_thumbnail_url = plugin_dir_url(__DIR__).'../images/person.png'; |
|
| 109 | + $organization_thumbnail_url = plugin_dir_url(__DIR__).'../images/organization.png'; |
|
| 110 | 110 | |
| 111 | 111 | // Get the current post. |
| 112 | - $current_post = $current_post_id ? get_post( $current_post_id ) : null; |
|
| 112 | + $current_post = $current_post_id ? get_post($current_post_id) : null; |
|
| 113 | 113 | |
| 114 | 114 | // Finally render the Select. |
| 115 | 115 | $this->select_element->render( |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | // The selected id. |
| 124 | 124 | 'value' => $current_post_id, |
| 125 | 125 | // The selected item (must be in the options for Select2 to display it). |
| 126 | - 'options' => $current_post ? array( $current_post->ID => $current_post->post_title ) : array(), |
|
| 126 | + 'options' => $current_post ? array($current_post->ID => $current_post->post_title) : array(), |
|
| 127 | 127 | // Data attributes. |
| 128 | 128 | 'data' => array( |
| 129 | 129 | // The list of available options. |
| 130 | - 'wl-select2-data' => wp_json_encode( $data ), |
|
| 130 | + 'wl-select2-data' => wp_json_encode($data), |
|
| 131 | 131 | // The HTML template for each option. |
| 132 | 132 | 'wl-select2-template-result' => "<div class='wl-select2-result'><span class='wl-select2-thumbnail' style='background-image: url( <%- obj.thumbnail_url || ( 'Organization' === obj.type ? '$organization_thumbnail_url' : '$person_thumbnail_url' ) %> );'> </span><span class='wl-select2'><%- obj.text %></span><span class='wl-select2-type'><%- obj.type %></span></div>", |
| 133 | 133 | // The HTML template for the selected option. |
@@ -18,54 +18,54 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Admin_Radio_Input_Element implements Wordlift_Admin_Element { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Output the HTML for an input box type settings_page. |
|
| 23 | - * |
|
| 24 | - * @param array $args { |
|
| 25 | - * An array of arguments. |
|
| 26 | - * |
|
| 27 | - * @type string $name The name attribute of the input element. Mandatory. |
|
| 28 | - * @type string $id The id attribute of the input element. Optional, |
|
| 29 | - * randomly generated one is used if not supplied. |
|
| 30 | - * @type string $value The value of the input element. Optional, defaults |
|
| 31 | - * to empty string. |
|
| 32 | - * @type string $css_class The class attribute for the input element. If empty |
|
| 33 | - * string no class attribute will be added. Optional, |
|
| 34 | - * defaults to empty string. |
|
| 35 | - * @type string $description The description text to be displayed below the element. |
|
| 36 | - * Can include some HTML element. If empty string no |
|
| 37 | - * description will be displayed. Optional, defaults to |
|
| 38 | - * empty string. |
|
| 39 | - * } |
|
| 40 | - * @return $this|Wordlift_Admin_Element |
|
| 41 | - * @since 3.13.0 |
|
| 42 | - */ |
|
| 43 | - public function render( $args ) { |
|
| 44 | - /* |
|
| 21 | + /** |
|
| 22 | + * Output the HTML for an input box type settings_page. |
|
| 23 | + * |
|
| 24 | + * @param array $args { |
|
| 25 | + * An array of arguments. |
|
| 26 | + * |
|
| 27 | + * @type string $name The name attribute of the input element. Mandatory. |
|
| 28 | + * @type string $id The id attribute of the input element. Optional, |
|
| 29 | + * randomly generated one is used if not supplied. |
|
| 30 | + * @type string $value The value of the input element. Optional, defaults |
|
| 31 | + * to empty string. |
|
| 32 | + * @type string $css_class The class attribute for the input element. If empty |
|
| 33 | + * string no class attribute will be added. Optional, |
|
| 34 | + * defaults to empty string. |
|
| 35 | + * @type string $description The description text to be displayed below the element. |
|
| 36 | + * Can include some HTML element. If empty string no |
|
| 37 | + * description will be displayed. Optional, defaults to |
|
| 38 | + * empty string. |
|
| 39 | + * } |
|
| 40 | + * @return $this|Wordlift_Admin_Element |
|
| 41 | + * @since 3.13.0 |
|
| 42 | + */ |
|
| 43 | + public function render( $args ) { |
|
| 44 | + /* |
|
| 45 | 45 | * Parse the arguments and merge with default values. |
| 46 | 46 | * Name intentionally do not have a default as it has to be in SyncEvent |
| 47 | 47 | * with form handling code |
| 48 | 48 | */ |
| 49 | - $params = wp_parse_args( |
|
| 50 | - $args, |
|
| 51 | - array( |
|
| 52 | - 'id' => uniqid( 'wl-input-' ), |
|
| 53 | - 'value' => '', |
|
| 54 | - 'css_class' => '', |
|
| 55 | - 'description' => '', |
|
| 56 | - ) |
|
| 57 | - ); |
|
| 49 | + $params = wp_parse_args( |
|
| 50 | + $args, |
|
| 51 | + array( |
|
| 52 | + 'id' => uniqid( 'wl-input-' ), |
|
| 53 | + 'value' => '', |
|
| 54 | + 'css_class' => '', |
|
| 55 | + 'description' => '', |
|
| 56 | + ) |
|
| 57 | + ); |
|
| 58 | 58 | |
| 59 | - // Set the readonly and class attributes and the description. |
|
| 60 | - $value = $params['value']; |
|
| 61 | - ?> |
|
| 59 | + // Set the readonly and class attributes and the description. |
|
| 60 | + $value = $params['value']; |
|
| 61 | + ?> |
|
| 62 | 62 | |
| 63 | 63 | <input type="radio" id="<?php echo esc_attr( $params['id'] ); ?>" |
| 64 | 64 | name="<?php echo esc_attr( $params['name'] ); ?>" |
| 65 | 65 | value="yes" |
| 66 | 66 | <?php |
| 67 | - if ( ! empty( $params['css_class'] ) ) { |
|
| 68 | - ?> |
|
| 67 | + if ( ! empty( $params['css_class'] ) ) { |
|
| 68 | + ?> |
|
| 69 | 69 | class="<?php echo esc_attr( $params['css_class'] ); ?>" <?php } ?> |
| 70 | 70 | <?php checked( $value, 'yes' ); ?> |
| 71 | 71 | /> Yes |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | name="<?php echo esc_attr( $params['name'] ); ?>" |
| 74 | 74 | value="no" |
| 75 | 75 | <?php |
| 76 | - if ( ! empty( $params['css_class'] ) ) { |
|
| 77 | - ?> |
|
| 76 | + if ( ! empty( $params['css_class'] ) ) { |
|
| 77 | + ?> |
|
| 78 | 78 | class="<?php echo esc_attr( $params['css_class'] ); ?>" <?php } ?> |
| 79 | 79 | <?php checked( $value, 'no' ); ?> |
| 80 | 80 | /> No |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | <p><?php echo wp_kses( $params['description'], array( 'a' => array( 'href' => array() ) ) ); ?></p><?php } ?> |
| 83 | 83 | <?php |
| 84 | 84 | |
| 85 | - return $this; |
|
| 86 | - } |
|
| 85 | + return $this; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @return $this|Wordlift_Admin_Element |
| 41 | 41 | * @since 3.13.0 |
| 42 | 42 | */ |
| 43 | - public function render( $args ) { |
|
| 43 | + public function render($args) { |
|
| 44 | 44 | /* |
| 45 | 45 | * Parse the arguments and merge with default values. |
| 46 | 46 | * Name intentionally do not have a default as it has to be in SyncEvent |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $params = wp_parse_args( |
| 50 | 50 | $args, |
| 51 | 51 | array( |
| 52 | - 'id' => uniqid( 'wl-input-' ), |
|
| 52 | + 'id' => uniqid('wl-input-'), |
|
| 53 | 53 | 'value' => '', |
| 54 | 54 | 'css_class' => '', |
| 55 | 55 | 'description' => '', |
@@ -60,26 +60,26 @@ discard block |
||
| 60 | 60 | $value = $params['value']; |
| 61 | 61 | ?> |
| 62 | 62 | |
| 63 | - <input type="radio" id="<?php echo esc_attr( $params['id'] ); ?>" |
|
| 64 | - name="<?php echo esc_attr( $params['name'] ); ?>" |
|
| 63 | + <input type="radio" id="<?php echo esc_attr($params['id']); ?>" |
|
| 64 | + name="<?php echo esc_attr($params['name']); ?>" |
|
| 65 | 65 | value="yes" |
| 66 | 66 | <?php |
| 67 | - if ( ! empty( $params['css_class'] ) ) { |
|
| 67 | + if ( ! empty($params['css_class'])) { |
|
| 68 | 68 | ?> |
| 69 | - class="<?php echo esc_attr( $params['css_class'] ); ?>" <?php } ?> |
|
| 70 | - <?php checked( $value, 'yes' ); ?> |
|
| 69 | + class="<?php echo esc_attr($params['css_class']); ?>" <?php } ?> |
|
| 70 | + <?php checked($value, 'yes'); ?> |
|
| 71 | 71 | /> Yes |
| 72 | - <input type="radio" id="<?php echo esc_attr( $params['id'] ); ?>" |
|
| 73 | - name="<?php echo esc_attr( $params['name'] ); ?>" |
|
| 72 | + <input type="radio" id="<?php echo esc_attr($params['id']); ?>" |
|
| 73 | + name="<?php echo esc_attr($params['name']); ?>" |
|
| 74 | 74 | value="no" |
| 75 | 75 | <?php |
| 76 | - if ( ! empty( $params['css_class'] ) ) { |
|
| 76 | + if ( ! empty($params['css_class'])) { |
|
| 77 | 77 | ?> |
| 78 | - class="<?php echo esc_attr( $params['css_class'] ); ?>" <?php } ?> |
|
| 79 | - <?php checked( $value, 'no' ); ?> |
|
| 78 | + class="<?php echo esc_attr($params['css_class']); ?>" <?php } ?> |
|
| 79 | + <?php checked($value, 'no'); ?> |
|
| 80 | 80 | /> No |
| 81 | - <?php if ( ! empty( $params['description'] ) ) { ?> |
|
| 82 | - <p><?php echo wp_kses( $params['description'], array( 'a' => array( 'href' => array() ) ) ); ?></p><?php } ?> |
|
| 81 | + <?php if ( ! empty($params['description'])) { ?> |
|
| 82 | + <p><?php echo wp_kses($params['description'], array('a' => array('href' => array()))); ?></p><?php } ?> |
|
| 83 | 83 | <?php |
| 84 | 84 | |
| 85 | 85 | return $this; |
@@ -18,37 +18,37 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Admin_Country_Select_Element extends Wordlift_Admin_Select_Element { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Adds a filter that will add data `country-codes` attrbiute to the country select |
|
| 23 | - * to allow front-end validation. |
|
| 24 | - * |
|
| 25 | - * @since 3.18.0 |
|
| 26 | - */ |
|
| 27 | - public function __construct() { |
|
| 28 | - // Adds the country codes as data attribute to allow front-end validation. |
|
| 29 | - add_filter( 'wl_admin_select_element_data_attributes', array( $this, 'add_country_codes_data' ), 10, 1 ); |
|
| 30 | - } |
|
| 21 | + /** |
|
| 22 | + * Adds a filter that will add data `country-codes` attrbiute to the country select |
|
| 23 | + * to allow front-end validation. |
|
| 24 | + * |
|
| 25 | + * @since 3.18.0 |
|
| 26 | + */ |
|
| 27 | + public function __construct() { |
|
| 28 | + // Adds the country codes as data attribute to allow front-end validation. |
|
| 29 | + add_filter( 'wl_admin_select_element_data_attributes', array( $this, 'add_country_codes_data' ), 10, 1 ); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @inheritdoc |
|
| 34 | - */ |
|
| 35 | - public function render_options( $params ) { |
|
| 36 | - // Print all the supported countries, preselecting the one configured |
|
| 37 | - // in WP (or United Kingdom if not supported). We now use the `Wordlift_Countries` |
|
| 38 | - // class which provides the list of countries supported by WordLift. |
|
| 39 | - // |
|
| 40 | - // https://github.com/insideout10/wordlift-plugin/issues/713 |
|
| 32 | + /** |
|
| 33 | + * @inheritdoc |
|
| 34 | + */ |
|
| 35 | + public function render_options( $params ) { |
|
| 36 | + // Print all the supported countries, preselecting the one configured |
|
| 37 | + // in WP (or United Kingdom if not supported). We now use the `Wordlift_Countries` |
|
| 38 | + // class which provides the list of countries supported by WordLift. |
|
| 39 | + // |
|
| 40 | + // https://github.com/insideout10/wordlift-plugin/issues/713 |
|
| 41 | 41 | |
| 42 | - $lang = ( isset( $params['lang'] ) ) ? $params['lang'] : false; |
|
| 42 | + $lang = ( isset( $params['lang'] ) ) ? $params['lang'] : false; |
|
| 43 | 43 | |
| 44 | - // Get WordLift's supported countries. |
|
| 45 | - $countries = Wordlift_Countries::get_countries( $lang ); |
|
| 44 | + // Get WordLift's supported countries. |
|
| 45 | + $countries = Wordlift_Countries::get_countries( $lang ); |
|
| 46 | 46 | |
| 47 | - // If we support WP's configured language, then use that, otherwise use English by default. |
|
| 48 | - $language = isset( $countries[ $params['value'] ] ) ? $params['value'] : 'uk'; |
|
| 47 | + // If we support WP's configured language, then use that, otherwise use English by default. |
|
| 48 | + $language = isset( $countries[ $params['value'] ] ) ? $params['value'] : 'uk'; |
|
| 49 | 49 | |
| 50 | - foreach ( $countries as $code => $label ) : |
|
| 51 | - ?> |
|
| 50 | + foreach ( $countries as $code => $label ) : |
|
| 51 | + ?> |
|
| 52 | 52 | <option |
| 53 | 53 | value="<?php echo esc_attr( $code ); ?>" |
| 54 | 54 | <?php echo selected( $code, $language, false ); ?> |
@@ -56,50 +56,50 @@ discard block |
||
| 56 | 56 | <?php echo esc_html( $label ); ?> |
| 57 | 57 | </option> |
| 58 | 58 | <?php |
| 59 | - endforeach; |
|
| 60 | - } |
|
| 59 | + endforeach; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Returns select options html. |
|
| 64 | - * |
|
| 65 | - * @since 3.18.0 |
|
| 66 | - * |
|
| 67 | - * @return void Echoes select options or empty string if required params are not set. |
|
| 68 | - */ |
|
| 69 | - public function get_options_html() { |
|
| 70 | - $html = ''; |
|
| 62 | + /** |
|
| 63 | + * Returns select options html. |
|
| 64 | + * |
|
| 65 | + * @since 3.18.0 |
|
| 66 | + * |
|
| 67 | + * @return void Echoes select options or empty string if required params are not set. |
|
| 68 | + */ |
|
| 69 | + public function get_options_html() { |
|
| 70 | + $html = ''; |
|
| 71 | 71 | |
| 72 | - // Check whether the required params are set. |
|
| 72 | + // Check whether the required params are set. |
|
| 73 | 73 | // phpcs:ignore Standard.Category.SniffName.ErrorCode |
| 74 | - if ( ! empty( $_POST['lang'] ) && ! empty( $_POST['value'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 75 | - ob_start(); |
|
| 76 | - // Get the new options. |
|
| 77 | - // phpcs:ignore Standard.Category.SniffName.ErrorCode |
|
| 78 | - $this->render_options( $_POST ); //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 74 | + if ( ! empty( $_POST['lang'] ) && ! empty( $_POST['value'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 75 | + ob_start(); |
|
| 76 | + // Get the new options. |
|
| 77 | + // phpcs:ignore Standard.Category.SniffName.ErrorCode |
|
| 78 | + $this->render_options( $_POST ); //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 79 | 79 | |
| 80 | - $html = ob_get_clean(); |
|
| 81 | - } |
|
| 80 | + $html = ob_get_clean(); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - // Return the html. |
|
| 84 | - wp_send_json_success( $html ); |
|
| 85 | - } |
|
| 83 | + // Return the html. |
|
| 84 | + wp_send_json_success( $html ); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * Modify the field data attributes by adding`country-code` |
|
| 89 | - * to existing attributes. |
|
| 90 | - * |
|
| 91 | - * @param array $attributes Current data attributes. |
|
| 92 | - * |
|
| 93 | - * @since 3.18.0 |
|
| 94 | - * |
|
| 95 | - * @return array $attributes Modified attributes. |
|
| 96 | - */ |
|
| 97 | - public function add_country_codes_data( $attributes ) { |
|
| 98 | - // Add the country codes. |
|
| 99 | - $attributes['country-codes'] = wp_json_encode( Wordlift_Countries::get_codes() ); |
|
| 87 | + /** |
|
| 88 | + * Modify the field data attributes by adding`country-code` |
|
| 89 | + * to existing attributes. |
|
| 90 | + * |
|
| 91 | + * @param array $attributes Current data attributes. |
|
| 92 | + * |
|
| 93 | + * @since 3.18.0 |
|
| 94 | + * |
|
| 95 | + * @return array $attributes Modified attributes. |
|
| 96 | + */ |
|
| 97 | + public function add_country_codes_data( $attributes ) { |
|
| 98 | + // Add the country codes. |
|
| 99 | + $attributes['country-codes'] = wp_json_encode( Wordlift_Countries::get_codes() ); |
|
| 100 | 100 | |
| 101 | - // Return the attributes. |
|
| 102 | - return $attributes; |
|
| 103 | - } |
|
| 101 | + // Return the attributes. |
|
| 102 | + return $attributes; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | } |
@@ -26,34 +26,34 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function __construct() { |
| 28 | 28 | // Adds the country codes as data attribute to allow front-end validation. |
| 29 | - add_filter( 'wl_admin_select_element_data_attributes', array( $this, 'add_country_codes_data' ), 10, 1 ); |
|
| 29 | + add_filter('wl_admin_select_element_data_attributes', array($this, 'add_country_codes_data'), 10, 1); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * @inheritdoc |
| 34 | 34 | */ |
| 35 | - public function render_options( $params ) { |
|
| 35 | + public function render_options($params) { |
|
| 36 | 36 | // Print all the supported countries, preselecting the one configured |
| 37 | 37 | // in WP (or United Kingdom if not supported). We now use the `Wordlift_Countries` |
| 38 | 38 | // class which provides the list of countries supported by WordLift. |
| 39 | 39 | // |
| 40 | 40 | // https://github.com/insideout10/wordlift-plugin/issues/713 |
| 41 | 41 | |
| 42 | - $lang = ( isset( $params['lang'] ) ) ? $params['lang'] : false; |
|
| 42 | + $lang = (isset($params['lang'])) ? $params['lang'] : false; |
|
| 43 | 43 | |
| 44 | 44 | // Get WordLift's supported countries. |
| 45 | - $countries = Wordlift_Countries::get_countries( $lang ); |
|
| 45 | + $countries = Wordlift_Countries::get_countries($lang); |
|
| 46 | 46 | |
| 47 | 47 | // If we support WP's configured language, then use that, otherwise use English by default. |
| 48 | - $language = isset( $countries[ $params['value'] ] ) ? $params['value'] : 'uk'; |
|
| 48 | + $language = isset($countries[$params['value']]) ? $params['value'] : 'uk'; |
|
| 49 | 49 | |
| 50 | - foreach ( $countries as $code => $label ) : |
|
| 50 | + foreach ($countries as $code => $label) : |
|
| 51 | 51 | ?> |
| 52 | 52 | <option |
| 53 | - value="<?php echo esc_attr( $code ); ?>" |
|
| 54 | - <?php echo selected( $code, $language, false ); ?> |
|
| 53 | + value="<?php echo esc_attr($code); ?>" |
|
| 54 | + <?php echo selected($code, $language, false); ?> |
|
| 55 | 55 | > |
| 56 | - <?php echo esc_html( $label ); ?> |
|
| 56 | + <?php echo esc_html($label); ?> |
|
| 57 | 57 | </option> |
| 58 | 58 | <?php |
| 59 | 59 | endforeach; |
@@ -71,17 +71,17 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | // Check whether the required params are set. |
| 73 | 73 | // phpcs:ignore Standard.Category.SniffName.ErrorCode |
| 74 | - if ( ! empty( $_POST['lang'] ) && ! empty( $_POST['value'] ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 74 | + if ( ! empty($_POST['lang']) && ! empty($_POST['value'])) { //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 75 | 75 | ob_start(); |
| 76 | 76 | // Get the new options. |
| 77 | 77 | // phpcs:ignore Standard.Category.SniffName.ErrorCode |
| 78 | - $this->render_options( $_POST ); //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 78 | + $this->render_options($_POST); //phpcs:ignore WordPress.Security.NonceVerification.Missing |
|
| 79 | 79 | |
| 80 | 80 | $html = ob_get_clean(); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // Return the html. |
| 84 | - wp_send_json_success( $html ); |
|
| 84 | + wp_send_json_success($html); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @return array $attributes Modified attributes. |
| 96 | 96 | */ |
| 97 | - public function add_country_codes_data( $attributes ) { |
|
| 97 | + public function add_country_codes_data($attributes) { |
|
| 98 | 98 | // Add the country codes. |
| 99 | - $attributes['country-codes'] = wp_json_encode( Wordlift_Countries::get_codes() ); |
|
| 99 | + $attributes['country-codes'] = wp_json_encode(Wordlift_Countries::get_codes()); |
|
| 100 | 100 | |
| 101 | 101 | // Return the attributes. |
| 102 | 102 | return $attributes; |
@@ -18,48 +18,48 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Admin_Tabs_Element implements Wordlift_Admin_Element { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Render the element. |
|
| 23 | - * |
|
| 24 | - * @param array $args { |
|
| 25 | - * Parameters controlling the html being output. |
|
| 26 | - * |
|
| 27 | - * @type integer $active The index of the active panel on first render |
|
| 28 | - * a zero based number of the tab actual placement |
|
| 29 | - * |
|
| 30 | - * @type array $tabs { |
|
| 31 | - * The array of tabs to be rendered. |
|
| 32 | - * The index of the elements is expected to be an ascending integers |
|
| 33 | - * tabs with lower index values will be render first (on the left) |
|
| 34 | - * |
|
| 35 | - * @type string $label The label used for the tab. |
|
| 36 | - * @type callable $callback The callback to call to render the |
|
| 37 | - * Tab "panel". |
|
| 38 | - * @type array $args The arguments array passed to the callback. |
|
| 39 | - * } |
|
| 40 | - * } |
|
| 41 | - * |
|
| 42 | - * @return \Wordlift_Admin_Element The element instance. |
|
| 43 | - * @since 3.11.0 |
|
| 44 | - */ |
|
| 45 | - public function render( $args ) { |
|
| 21 | + /** |
|
| 22 | + * Render the element. |
|
| 23 | + * |
|
| 24 | + * @param array $args { |
|
| 25 | + * Parameters controlling the html being output. |
|
| 26 | + * |
|
| 27 | + * @type integer $active The index of the active panel on first render |
|
| 28 | + * a zero based number of the tab actual placement |
|
| 29 | + * |
|
| 30 | + * @type array $tabs { |
|
| 31 | + * The array of tabs to be rendered. |
|
| 32 | + * The index of the elements is expected to be an ascending integers |
|
| 33 | + * tabs with lower index values will be render first (on the left) |
|
| 34 | + * |
|
| 35 | + * @type string $label The label used for the tab. |
|
| 36 | + * @type callable $callback The callback to call to render the |
|
| 37 | + * Tab "panel". |
|
| 38 | + * @type array $args The arguments array passed to the callback. |
|
| 39 | + * } |
|
| 40 | + * } |
|
| 41 | + * |
|
| 42 | + * @return \Wordlift_Admin_Element The element instance. |
|
| 43 | + * @since 3.11.0 |
|
| 44 | + */ |
|
| 45 | + public function render( $args ) { |
|
| 46 | 46 | |
| 47 | - // Enqueue the jQuery UI Tabs script. |
|
| 48 | - wp_enqueue_script( 'jquery-ui-tabs' ); |
|
| 47 | + // Enqueue the jQuery UI Tabs script. |
|
| 48 | + wp_enqueue_script( 'jquery-ui-tabs' ); |
|
| 49 | 49 | |
| 50 | - // Parse the arguments and merge with default values. |
|
| 51 | - $params = wp_parse_args( |
|
| 52 | - $args, |
|
| 53 | - array( |
|
| 54 | - 'tabs' => array(), |
|
| 55 | - 'active' => 0, |
|
| 56 | - ) |
|
| 57 | - ); |
|
| 50 | + // Parse the arguments and merge with default values. |
|
| 51 | + $params = wp_parse_args( |
|
| 52 | + $args, |
|
| 53 | + array( |
|
| 54 | + 'tabs' => array(), |
|
| 55 | + 'active' => 0, |
|
| 56 | + ) |
|
| 57 | + ); |
|
| 58 | 58 | |
| 59 | - // Following is the HTML code: |
|
| 60 | - // - the labels are printed, using the tab's `label`, |
|
| 61 | - // - the panels are printed, using the tab's `callback`. |
|
| 62 | - ?> |
|
| 59 | + // Following is the HTML code: |
|
| 60 | + // - the labels are printed, using the tab's `label`, |
|
| 61 | + // - the panels are printed, using the tab's `callback`. |
|
| 62 | + ?> |
|
| 63 | 63 | <div |
| 64 | 64 | class="wl-tabs-element" |
| 65 | 65 | data-active="<?php echo esc_attr( $params['active'] ); ?>" |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | <?php |
| 84 | 84 | |
| 85 | - return $this; |
|
| 86 | - } |
|
| 85 | + return $this; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | } |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | * @return \Wordlift_Admin_Element The element instance. |
| 43 | 43 | * @since 3.11.0 |
| 44 | 44 | */ |
| 45 | - public function render( $args ) { |
|
| 45 | + public function render($args) { |
|
| 46 | 46 | |
| 47 | 47 | // Enqueue the jQuery UI Tabs script. |
| 48 | - wp_enqueue_script( 'jquery-ui-tabs' ); |
|
| 48 | + wp_enqueue_script('jquery-ui-tabs'); |
|
| 49 | 49 | |
| 50 | 50 | // Parse the arguments and merge with default values. |
| 51 | 51 | $params = wp_parse_args( |
@@ -62,20 +62,20 @@ discard block |
||
| 62 | 62 | ?> |
| 63 | 63 | <div |
| 64 | 64 | class="wl-tabs-element" |
| 65 | - data-active="<?php echo esc_attr( $params['active'] ); ?>" |
|
| 65 | + data-active="<?php echo esc_attr($params['active']); ?>" |
|
| 66 | 66 | > |
| 67 | 67 | <ul class="nav-tab-wrapper"> |
| 68 | - <?php foreach ( $params['tabs'] as $index => $tab ) : ?> |
|
| 68 | + <?php foreach ($params['tabs'] as $index => $tab) : ?> |
|
| 69 | 69 | <li class="nav-tab"> |
| 70 | - <a href="#tabs-<?php echo esc_html( $index + 1 ); ?>"> |
|
| 71 | - <?php echo esc_html( $tab['label'] ); ?> |
|
| 70 | + <a href="#tabs-<?php echo esc_html($index + 1); ?>"> |
|
| 71 | + <?php echo esc_html($tab['label']); ?> |
|
| 72 | 72 | </a> |
| 73 | 73 | </li> |
| 74 | 74 | <?php endforeach; ?> |
| 75 | 75 | </ul> |
| 76 | - <?php foreach ( $params['tabs'] as $index => $tab ) : ?> |
|
| 77 | - <div id="tabs-<?php echo esc_html( $index + 1 ); ?>"> |
|
| 78 | - <?php call_user_func( $tab['callback'], $tab['args'] ); ?> |
|
| 76 | + <?php foreach ($params['tabs'] as $index => $tab) : ?> |
|
| 77 | + <div id="tabs-<?php echo esc_html($index + 1); ?>"> |
|
| 78 | + <?php call_user_func($tab['callback'], $tab['args']); ?> |
|
| 79 | 79 | </div> |
| 80 | 80 | <?php endforeach; ?> |
| 81 | 81 | </div> |
@@ -18,13 +18,13 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Admin_Select2_Element extends Wordlift_Admin_Select_Element { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @inheritdoc |
|
| 23 | - */ |
|
| 24 | - public function render_options( $params ) { |
|
| 25 | - // Loop through all params and add the options. |
|
| 26 | - foreach ( $params['options'] as $value => $label ) : |
|
| 27 | - ?> |
|
| 21 | + /** |
|
| 22 | + * @inheritdoc |
|
| 23 | + */ |
|
| 24 | + public function render_options( $params ) { |
|
| 25 | + // Loop through all params and add the options. |
|
| 26 | + foreach ( $params['options'] as $value => $label ) : |
|
| 27 | + ?> |
|
| 28 | 28 | <option |
| 29 | 29 | value="<?php echo esc_attr( $value ); ?>" |
| 30 | 30 | <?php selected( $params['value'], $value ); ?> |
@@ -32,26 +32,26 @@ discard block |
||
| 32 | 32 | <?php echo esc_html( $label ); ?> |
| 33 | 33 | </option> |
| 34 | 34 | <?php |
| 35 | - endforeach; |
|
| 36 | - } |
|
| 35 | + endforeach; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @inheritdoc |
|
| 40 | - */ |
|
| 41 | - protected function enqueue_resources() { |
|
| 42 | - // Enqueue select2 library js and css. |
|
| 43 | - // Underscore is needed for Select2's `templateResult` and `templateSelection` templates. |
|
| 44 | - wp_enqueue_script( |
|
| 45 | - 'wordlift-select2', |
|
| 46 | - plugin_dir_url( __DIR__ ) . 'js/select2/js/select2' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.js', |
|
| 47 | - array( |
|
| 48 | - 'jquery', |
|
| 49 | - 'underscore', |
|
| 50 | - ), |
|
| 51 | - '4.0.3', |
|
| 52 | - false |
|
| 53 | - ); |
|
| 54 | - wp_enqueue_style( 'wordlift-select2', plugin_dir_url( __DIR__ ) . 'js/select2/css/select2' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.css', array(), '4.0.3' ); |
|
| 55 | - } |
|
| 38 | + /** |
|
| 39 | + * @inheritdoc |
|
| 40 | + */ |
|
| 41 | + protected function enqueue_resources() { |
|
| 42 | + // Enqueue select2 library js and css. |
|
| 43 | + // Underscore is needed for Select2's `templateResult` and `templateSelection` templates. |
|
| 44 | + wp_enqueue_script( |
|
| 45 | + 'wordlift-select2', |
|
| 46 | + plugin_dir_url( __DIR__ ) . 'js/select2/js/select2' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.js', |
|
| 47 | + array( |
|
| 48 | + 'jquery', |
|
| 49 | + 'underscore', |
|
| 50 | + ), |
|
| 51 | + '4.0.3', |
|
| 52 | + false |
|
| 53 | + ); |
|
| 54 | + wp_enqueue_style( 'wordlift-select2', plugin_dir_url( __DIR__ ) . 'js/select2/css/select2' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.css', array(), '4.0.3' ); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | } |
@@ -21,15 +21,15 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * @inheritdoc |
| 23 | 23 | */ |
| 24 | - public function render_options( $params ) { |
|
| 24 | + public function render_options($params) { |
|
| 25 | 25 | // Loop through all params and add the options. |
| 26 | - foreach ( $params['options'] as $value => $label ) : |
|
| 26 | + foreach ($params['options'] as $value => $label) : |
|
| 27 | 27 | ?> |
| 28 | 28 | <option |
| 29 | - value="<?php echo esc_attr( $value ); ?>" |
|
| 30 | - <?php selected( $params['value'], $value ); ?> |
|
| 29 | + value="<?php echo esc_attr($value); ?>" |
|
| 30 | + <?php selected($params['value'], $value); ?> |
|
| 31 | 31 | > |
| 32 | - <?php echo esc_html( $label ); ?> |
|
| 32 | + <?php echo esc_html($label); ?> |
|
| 33 | 33 | </option> |
| 34 | 34 | <?php |
| 35 | 35 | endforeach; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | // Underscore is needed for Select2's `templateResult` and `templateSelection` templates. |
| 44 | 44 | wp_enqueue_script( |
| 45 | 45 | 'wordlift-select2', |
| 46 | - plugin_dir_url( __DIR__ ) . 'js/select2/js/select2' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.js', |
|
| 46 | + plugin_dir_url(__DIR__).'js/select2/js/select2'.( ! defined('SCRIPT_DEBUG') || ! SCRIPT_DEBUG ? '.min' : '').'.js', |
|
| 47 | 47 | array( |
| 48 | 48 | 'jquery', |
| 49 | 49 | 'underscore', |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | '4.0.3', |
| 52 | 52 | false |
| 53 | 53 | ); |
| 54 | - wp_enqueue_style( 'wordlift-select2', plugin_dir_url( __DIR__ ) . 'js/select2/css/select2' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.css', array(), '4.0.3' ); |
|
| 54 | + wp_enqueue_style('wordlift-select2', plugin_dir_url(__DIR__).'js/select2/css/select2'.( ! defined('SCRIPT_DEBUG') || ! SCRIPT_DEBUG ? '.min' : '').'.css', array(), '4.0.3'); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | } |
@@ -18,11 +18,11 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Admin_Language_Select_Element extends Wordlift_Admin_Select_Element { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @inheritdoc |
|
| 23 | - */ |
|
| 24 | - public function render_options( $params ) { |
|
| 25 | - /* |
|
| 21 | + /** |
|
| 22 | + * @inheritdoc |
|
| 23 | + */ |
|
| 24 | + public function render_options( $params ) { |
|
| 25 | + /* |
|
| 26 | 26 | * Print all the supported language, preselecting the one configured |
| 27 | 27 | * in WP (or English if not supported). We now use the `Wordlift_Languages` |
| 28 | 28 | * class which provides the list of languages supported by WordLift. |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | * See https://github.com/insideout10/wordlift-plugin/issues/349 |
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | - // Get WordLift's supported languages. |
|
| 34 | - $languages = Wordlift_Languages::get_languages(); |
|
| 33 | + // Get WordLift's supported languages. |
|
| 34 | + $languages = Wordlift_Languages::get_languages(); |
|
| 35 | 35 | |
| 36 | - // If we support WP's configured language, then use that, otherwise use English by default. |
|
| 37 | - $language = isset( $languages[ $params['value'] ] ) ? $params['value'] : 'en'; |
|
| 36 | + // If we support WP's configured language, then use that, otherwise use English by default. |
|
| 37 | + $language = isset( $languages[ $params['value'] ] ) ? $params['value'] : 'en'; |
|
| 38 | 38 | |
| 39 | - foreach ( $languages as $code => $label ) : |
|
| 40 | - ?> |
|
| 39 | + foreach ( $languages as $code => $label ) : |
|
| 40 | + ?> |
|
| 41 | 41 | <option |
| 42 | 42 | value="<?php echo esc_attr( $code ); ?>" |
| 43 | 43 | <?php echo selected( $code, $language, false ); ?> |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | <?php echo esc_html( $label ); ?> |
| 46 | 46 | </option> |
| 47 | 47 | <?php |
| 48 | - endforeach; |
|
| 49 | - } |
|
| 48 | + endforeach; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * @inheritdoc |
| 23 | 23 | */ |
| 24 | - public function render_options( $params ) { |
|
| 24 | + public function render_options($params) { |
|
| 25 | 25 | /* |
| 26 | 26 | * Print all the supported language, preselecting the one configured |
| 27 | 27 | * in WP (or English if not supported). We now use the `Wordlift_Languages` |
@@ -34,15 +34,15 @@ discard block |
||
| 34 | 34 | $languages = Wordlift_Languages::get_languages(); |
| 35 | 35 | |
| 36 | 36 | // If we support WP's configured language, then use that, otherwise use English by default. |
| 37 | - $language = isset( $languages[ $params['value'] ] ) ? $params['value'] : 'en'; |
|
| 37 | + $language = isset($languages[$params['value']]) ? $params['value'] : 'en'; |
|
| 38 | 38 | |
| 39 | - foreach ( $languages as $code => $label ) : |
|
| 39 | + foreach ($languages as $code => $label) : |
|
| 40 | 40 | ?> |
| 41 | 41 | <option |
| 42 | - value="<?php echo esc_attr( $code ); ?>" |
|
| 43 | - <?php echo selected( $code, $language, false ); ?> |
|
| 42 | + value="<?php echo esc_attr($code); ?>" |
|
| 43 | + <?php echo selected($code, $language, false); ?> |
|
| 44 | 44 | > |
| 45 | - <?php echo esc_html( $label ); ?> |
|
| 45 | + <?php echo esc_html($label); ?> |
|
| 46 | 46 | </option> |
| 47 | 47 | <?php |
| 48 | 48 | endforeach; |
@@ -19,120 +19,120 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | class Wordlift_Admin_Publisher_Element extends Wordlift_Admin_Author_Element { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * The {@link Wordlift_Publisher_Service} instance. |
|
| 24 | - * |
|
| 25 | - * @since 3.11.0 |
|
| 26 | - * @access private |
|
| 27 | - * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 28 | - */ |
|
| 29 | - private $publisher_service; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var Wordlift_Admin_Tabs_Element |
|
| 33 | - */ |
|
| 34 | - private $tabs_element; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Create a {@link Wordlift_Admin_Publisher_Element} instance. |
|
| 38 | - * |
|
| 39 | - * @param \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 40 | - * @param \Wordlift_Admin_Tabs_Element $tabs_element The {@link Wordlift_Admin_Tabs_Element} instance. |
|
| 41 | - * @param \Wordlift_Admin_Select2_Element $select_element The {@link Wordlift_Admin_Select_Element} instance. |
|
| 42 | - * |
|
| 43 | - * @since 3.11.0 |
|
| 44 | - */ |
|
| 45 | - public function __construct( $publisher_service, $tabs_element, $select_element ) { |
|
| 46 | - parent::__construct( $publisher_service, $select_element ); |
|
| 47 | - |
|
| 48 | - $this->publisher_service = $publisher_service; |
|
| 49 | - |
|
| 50 | - // Child elements. |
|
| 51 | - $this->tabs_element = $tabs_element; |
|
| 52 | - |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @inheritdoc |
|
| 57 | - */ |
|
| 58 | - public function render( $args ) { |
|
| 59 | - |
|
| 60 | - // Parse the arguments and merge with default values. |
|
| 61 | - $params = wp_parse_args( |
|
| 62 | - $args, |
|
| 63 | - array( |
|
| 64 | - 'id' => uniqid( 'wl-input-' ), |
|
| 65 | - 'name' => uniqid( 'wl-input-' ), |
|
| 66 | - ) |
|
| 67 | - ); |
|
| 68 | - |
|
| 69 | - // Get the number of potential candidates as publishers. |
|
| 70 | - $count = $this->publisher_service->count(); |
|
| 71 | - |
|
| 72 | - $this->tabs_element->render( |
|
| 73 | - array( |
|
| 74 | - 'tabs' => array( |
|
| 75 | - array( |
|
| 76 | - 'label' => __( 'Select an Existing Publisher', 'wordlift' ), |
|
| 77 | - 'callback' => array( $this, 'select' ), |
|
| 78 | - 'args' => $params, |
|
| 79 | - ), |
|
| 80 | - array( |
|
| 81 | - 'label' => __( 'Create a New Publisher', 'wordlift' ), |
|
| 82 | - 'callback' => array( $this, 'create' ), |
|
| 83 | - 'args' => $params, |
|
| 84 | - ), |
|
| 85 | - ), |
|
| 86 | - // Set the default tab according to the number of potential publishers |
|
| 87 | - // configured in WP: 0 = select, 1 = create. |
|
| 88 | - 'active' => 0 === $count ? 1 : 0, |
|
| 89 | - ) |
|
| 90 | - ); |
|
| 91 | - |
|
| 92 | - // Finally return the element instance. |
|
| 93 | - return $this; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Render the publisher's select. |
|
| 98 | - * |
|
| 99 | - * @param array $params An array of parameters. |
|
| 100 | - * |
|
| 101 | - * @since 3.11.0 |
|
| 102 | - */ |
|
| 103 | - public function select( $params ) { |
|
| 104 | - |
|
| 105 | - // Get the configured publisher id. In case a publisher id is already configured |
|
| 106 | - // this must be pre-loaded in the options. |
|
| 107 | - $publisher_id = Wordlift_Configuration_Service::get_instance()->get_publisher_id(); |
|
| 108 | - |
|
| 109 | - // Get the publisher data. |
|
| 110 | - $data = $this->publisher_service->query(); |
|
| 111 | - array_unshift( |
|
| 112 | - $data, |
|
| 113 | - array( |
|
| 114 | - 'id' => '', |
|
| 115 | - 'text' => _x( '(none)', 'Publisher Select in Settings Screen.', 'wordlift' ), |
|
| 116 | - 'type' => '', |
|
| 117 | - 'thumbnail_url' => false, |
|
| 118 | - ) |
|
| 119 | - ); |
|
| 120 | - |
|
| 121 | - // Call the select internal render. |
|
| 122 | - $this->do_render( $params, $publisher_id, $data ); |
|
| 123 | - |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Render the 'create publisher' form. |
|
| 128 | - * |
|
| 129 | - * @param array $params An array of parameters. |
|
| 130 | - * |
|
| 131 | - * @since 3.11.0 |
|
| 132 | - */ |
|
| 22 | + /** |
|
| 23 | + * The {@link Wordlift_Publisher_Service} instance. |
|
| 24 | + * |
|
| 25 | + * @since 3.11.0 |
|
| 26 | + * @access private |
|
| 27 | + * @var \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 28 | + */ |
|
| 29 | + private $publisher_service; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var Wordlift_Admin_Tabs_Element |
|
| 33 | + */ |
|
| 34 | + private $tabs_element; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Create a {@link Wordlift_Admin_Publisher_Element} instance. |
|
| 38 | + * |
|
| 39 | + * @param \Wordlift_Publisher_Service $publisher_service The {@link Wordlift_Publisher_Service} instance. |
|
| 40 | + * @param \Wordlift_Admin_Tabs_Element $tabs_element The {@link Wordlift_Admin_Tabs_Element} instance. |
|
| 41 | + * @param \Wordlift_Admin_Select2_Element $select_element The {@link Wordlift_Admin_Select_Element} instance. |
|
| 42 | + * |
|
| 43 | + * @since 3.11.0 |
|
| 44 | + */ |
|
| 45 | + public function __construct( $publisher_service, $tabs_element, $select_element ) { |
|
| 46 | + parent::__construct( $publisher_service, $select_element ); |
|
| 47 | + |
|
| 48 | + $this->publisher_service = $publisher_service; |
|
| 49 | + |
|
| 50 | + // Child elements. |
|
| 51 | + $this->tabs_element = $tabs_element; |
|
| 52 | + |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @inheritdoc |
|
| 57 | + */ |
|
| 58 | + public function render( $args ) { |
|
| 59 | + |
|
| 60 | + // Parse the arguments and merge with default values. |
|
| 61 | + $params = wp_parse_args( |
|
| 62 | + $args, |
|
| 63 | + array( |
|
| 64 | + 'id' => uniqid( 'wl-input-' ), |
|
| 65 | + 'name' => uniqid( 'wl-input-' ), |
|
| 66 | + ) |
|
| 67 | + ); |
|
| 68 | + |
|
| 69 | + // Get the number of potential candidates as publishers. |
|
| 70 | + $count = $this->publisher_service->count(); |
|
| 71 | + |
|
| 72 | + $this->tabs_element->render( |
|
| 73 | + array( |
|
| 74 | + 'tabs' => array( |
|
| 75 | + array( |
|
| 76 | + 'label' => __( 'Select an Existing Publisher', 'wordlift' ), |
|
| 77 | + 'callback' => array( $this, 'select' ), |
|
| 78 | + 'args' => $params, |
|
| 79 | + ), |
|
| 80 | + array( |
|
| 81 | + 'label' => __( 'Create a New Publisher', 'wordlift' ), |
|
| 82 | + 'callback' => array( $this, 'create' ), |
|
| 83 | + 'args' => $params, |
|
| 84 | + ), |
|
| 85 | + ), |
|
| 86 | + // Set the default tab according to the number of potential publishers |
|
| 87 | + // configured in WP: 0 = select, 1 = create. |
|
| 88 | + 'active' => 0 === $count ? 1 : 0, |
|
| 89 | + ) |
|
| 90 | + ); |
|
| 91 | + |
|
| 92 | + // Finally return the element instance. |
|
| 93 | + return $this; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Render the publisher's select. |
|
| 98 | + * |
|
| 99 | + * @param array $params An array of parameters. |
|
| 100 | + * |
|
| 101 | + * @since 3.11.0 |
|
| 102 | + */ |
|
| 103 | + public function select( $params ) { |
|
| 104 | + |
|
| 105 | + // Get the configured publisher id. In case a publisher id is already configured |
|
| 106 | + // this must be pre-loaded in the options. |
|
| 107 | + $publisher_id = Wordlift_Configuration_Service::get_instance()->get_publisher_id(); |
|
| 108 | + |
|
| 109 | + // Get the publisher data. |
|
| 110 | + $data = $this->publisher_service->query(); |
|
| 111 | + array_unshift( |
|
| 112 | + $data, |
|
| 113 | + array( |
|
| 114 | + 'id' => '', |
|
| 115 | + 'text' => _x( '(none)', 'Publisher Select in Settings Screen.', 'wordlift' ), |
|
| 116 | + 'type' => '', |
|
| 117 | + 'thumbnail_url' => false, |
|
| 118 | + ) |
|
| 119 | + ); |
|
| 120 | + |
|
| 121 | + // Call the select internal render. |
|
| 122 | + $this->do_render( $params, $publisher_id, $data ); |
|
| 123 | + |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Render the 'create publisher' form. |
|
| 128 | + * |
|
| 129 | + * @param array $params An array of parameters. |
|
| 130 | + * |
|
| 131 | + * @since 3.11.0 |
|
| 132 | + */ |
|
| 133 | 133 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 134 | - public function create( $params ) { |
|
| 135 | - ?> |
|
| 134 | + public function create( $params ) { |
|
| 135 | + ?> |
|
| 136 | 136 | <p> |
| 137 | 137 | <strong><?php esc_html_e( 'Are you publishing as an individual or as a company?', 'wordlift' ); ?></strong> |
| 138 | 138 | </p> |
@@ -197,6 +197,6 @@ discard block |
||
| 197 | 197 | </p> |
| 198 | 198 | </div> |
| 199 | 199 | <?php |
| 200 | - } |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | 202 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @since 3.11.0 |
| 44 | 44 | */ |
| 45 | - public function __construct( $publisher_service, $tabs_element, $select_element ) { |
|
| 46 | - parent::__construct( $publisher_service, $select_element ); |
|
| 45 | + public function __construct($publisher_service, $tabs_element, $select_element) { |
|
| 46 | + parent::__construct($publisher_service, $select_element); |
|
| 47 | 47 | |
| 48 | 48 | $this->publisher_service = $publisher_service; |
| 49 | 49 | |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * @inheritdoc |
| 57 | 57 | */ |
| 58 | - public function render( $args ) { |
|
| 58 | + public function render($args) { |
|
| 59 | 59 | |
| 60 | 60 | // Parse the arguments and merge with default values. |
| 61 | 61 | $params = wp_parse_args( |
| 62 | 62 | $args, |
| 63 | 63 | array( |
| 64 | - 'id' => uniqid( 'wl-input-' ), |
|
| 65 | - 'name' => uniqid( 'wl-input-' ), |
|
| 64 | + 'id' => uniqid('wl-input-'), |
|
| 65 | + 'name' => uniqid('wl-input-'), |
|
| 66 | 66 | ) |
| 67 | 67 | ); |
| 68 | 68 | |
@@ -73,13 +73,13 @@ discard block |
||
| 73 | 73 | array( |
| 74 | 74 | 'tabs' => array( |
| 75 | 75 | array( |
| 76 | - 'label' => __( 'Select an Existing Publisher', 'wordlift' ), |
|
| 77 | - 'callback' => array( $this, 'select' ), |
|
| 76 | + 'label' => __('Select an Existing Publisher', 'wordlift'), |
|
| 77 | + 'callback' => array($this, 'select'), |
|
| 78 | 78 | 'args' => $params, |
| 79 | 79 | ), |
| 80 | 80 | array( |
| 81 | - 'label' => __( 'Create a New Publisher', 'wordlift' ), |
|
| 82 | - 'callback' => array( $this, 'create' ), |
|
| 81 | + 'label' => __('Create a New Publisher', 'wordlift'), |
|
| 82 | + 'callback' => array($this, 'create'), |
|
| 83 | 83 | 'args' => $params, |
| 84 | 84 | ), |
| 85 | 85 | ), |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @since 3.11.0 |
| 102 | 102 | */ |
| 103 | - public function select( $params ) { |
|
| 103 | + public function select($params) { |
|
| 104 | 104 | |
| 105 | 105 | // Get the configured publisher id. In case a publisher id is already configured |
| 106 | 106 | // this must be pre-loaded in the options. |
@@ -112,14 +112,14 @@ discard block |
||
| 112 | 112 | $data, |
| 113 | 113 | array( |
| 114 | 114 | 'id' => '', |
| 115 | - 'text' => _x( '(none)', 'Publisher Select in Settings Screen.', 'wordlift' ), |
|
| 115 | + 'text' => _x('(none)', 'Publisher Select in Settings Screen.', 'wordlift'), |
|
| 116 | 116 | 'type' => '', |
| 117 | 117 | 'thumbnail_url' => false, |
| 118 | 118 | ) |
| 119 | 119 | ); |
| 120 | 120 | |
| 121 | 121 | // Call the select internal render. |
| 122 | - $this->do_render( $params, $publisher_id, $data ); |
|
| 122 | + $this->do_render($params, $publisher_id, $data); |
|
| 123 | 123 | |
| 124 | 124 | } |
| 125 | 125 | |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | * @since 3.11.0 |
| 132 | 132 | */ |
| 133 | 133 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 134 | - public function create( $params ) { |
|
| 134 | + public function create($params) { |
|
| 135 | 135 | ?> |
| 136 | 136 | <p> |
| 137 | - <strong><?php esc_html_e( 'Are you publishing as an individual or as a company?', 'wordlift' ); ?></strong> |
|
| 137 | + <strong><?php esc_html_e('Are you publishing as an individual or as a company?', 'wordlift'); ?></strong> |
|
| 138 | 138 | </p> |
| 139 | 139 | |
| 140 | 140 | <p id="wl-publisher-type"> |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | > |
| 149 | 149 | |
| 150 | 150 | <label for="wl-publisher-person"> |
| 151 | - <?php esc_html_e( 'Person', 'wordlift' ); ?> |
|
| 151 | + <?php esc_html_e('Person', 'wordlift'); ?> |
|
| 152 | 152 | </label> |
| 153 | 153 | </span> |
| 154 | 154 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | > |
| 162 | 162 | |
| 163 | 163 | <label for="wl-publisher-company"> |
| 164 | - <?php esc_html_e( 'Company', 'wordlift' ); ?> |
|
| 164 | + <?php esc_html_e('Company', 'wordlift'); ?> |
|
| 165 | 165 | </label> |
| 166 | 166 | </span> |
| 167 | 167 | </p> |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | <input |
| 171 | 171 | type="text" |
| 172 | 172 | name="wl_publisher[name]" |
| 173 | - placeholder="<?php echo esc_attr__( "What's your name?", 'wordlift' ); ?>" |
|
| 173 | + placeholder="<?php echo esc_attr__("What's your name?", 'wordlift'); ?>" |
|
| 174 | 174 | > |
| 175 | 175 | </p> |
| 176 | 176 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | /> |
| 183 | 183 | |
| 184 | 184 | <p> |
| 185 | - <b><?php esc_html_e( "Choose the publisher's Logo", 'wordlift' ); ?></b> |
|
| 185 | + <b><?php esc_html_e("Choose the publisher's Logo", 'wordlift'); ?></b> |
|
| 186 | 186 | </p> |
| 187 | 187 | |
| 188 | 188 | <p> |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | type="button" |
| 193 | 193 | class="button" |
| 194 | 194 | id="wl-publisher-media-uploader"> |
| 195 | - <?php esc_html_e( 'Select an existing image or upload a new one', 'wordlift' ); ?> |
|
| 195 | + <?php esc_html_e('Select an existing image or upload a new one', 'wordlift'); ?> |
|
| 196 | 196 | </button> |
| 197 | 197 | </p> |
| 198 | 198 | </div> |
@@ -19,55 +19,55 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Wordlift_Admin_Settings_Analytics_Page_Action_Link { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * The {@link Wordlift_Admin_Settings_Analytics_Page} instance. |
|
| 24 | - * |
|
| 25 | - * @since 3.11.0 |
|
| 26 | - * @access private |
|
| 27 | - * @var \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance. |
|
| 28 | - */ |
|
| 29 | - private $settings_page; |
|
| 22 | + /** |
|
| 23 | + * The {@link Wordlift_Admin_Settings_Analytics_Page} instance. |
|
| 24 | + * |
|
| 25 | + * @since 3.11.0 |
|
| 26 | + * @access private |
|
| 27 | + * @var \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance. |
|
| 28 | + */ |
|
| 29 | + private $settings_page; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Create a {@link Wordlift_Admin_Settings_Analytics_Page_Action_Link} instance. |
|
| 33 | - * |
|
| 34 | - * @since 3.11.0 |
|
| 35 | - * |
|
| 36 | - * @param \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance. |
|
| 37 | - */ |
|
| 38 | - public function __construct( $settings_page ) { |
|
| 31 | + /** |
|
| 32 | + * Create a {@link Wordlift_Admin_Settings_Analytics_Page_Action_Link} instance. |
|
| 33 | + * |
|
| 34 | + * @since 3.11.0 |
|
| 35 | + * |
|
| 36 | + * @param \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance. |
|
| 37 | + */ |
|
| 38 | + public function __construct( $settings_page ) { |
|
| 39 | 39 | |
| 40 | - $this->settings_page = $settings_page; |
|
| 40 | + $this->settings_page = $settings_page; |
|
| 41 | 41 | |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Create a link to the WordLift settings page. |
|
| 46 | - * |
|
| 47 | - * @since 3.11.0 |
|
| 48 | - * |
|
| 49 | - * @param array $links An array of links. |
|
| 50 | - * |
|
| 51 | - * @return array An array of links including those added by the plugin. |
|
| 52 | - */ |
|
| 53 | - public function action_links( $links ) { |
|
| 44 | + /** |
|
| 45 | + * Create a link to the WordLift settings page. |
|
| 46 | + * |
|
| 47 | + * @since 3.11.0 |
|
| 48 | + * |
|
| 49 | + * @param array $links An array of links. |
|
| 50 | + * |
|
| 51 | + * @return array An array of links including those added by the plugin. |
|
| 52 | + */ |
|
| 53 | + public function action_links( $links ) { |
|
| 54 | 54 | |
| 55 | - // Get the menu slug from the page, then prepare the path, hence the url. |
|
| 56 | - $menu_slug = $this->settings_page->get_menu_slug(); |
|
| 57 | - $path = "admin.php?page=$menu_slug"; |
|
| 58 | - $url = get_admin_url( null, $path ); |
|
| 55 | + // Get the menu slug from the page, then prepare the path, hence the url. |
|
| 56 | + $menu_slug = $this->settings_page->get_menu_slug(); |
|
| 57 | + $path = "admin.php?page=$menu_slug"; |
|
| 58 | + $url = get_admin_url( null, $path ); |
|
| 59 | 59 | |
| 60 | - // Add our own link to the list of links. |
|
| 61 | - return array_merge( |
|
| 62 | - $links, |
|
| 63 | - array( |
|
| 64 | - sprintf( |
|
| 65 | - '<a href="%1$s">%2$s</a>', |
|
| 66 | - esc_url( $url ), |
|
| 67 | - esc_html__( 'Analytics Settings', 'wordlift' ) |
|
| 68 | - ), |
|
| 69 | - ) |
|
| 70 | - ); |
|
| 71 | - } |
|
| 60 | + // Add our own link to the list of links. |
|
| 61 | + return array_merge( |
|
| 62 | + $links, |
|
| 63 | + array( |
|
| 64 | + sprintf( |
|
| 65 | + '<a href="%1$s">%2$s</a>', |
|
| 66 | + esc_url( $url ), |
|
| 67 | + esc_html__( 'Analytics Settings', 'wordlift' ) |
|
| 68 | + ), |
|
| 69 | + ) |
|
| 70 | + ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param \Wordlift_Admin_Settings_Analytics_Page $settings_page The {@link Wordlift_Admin_Settings_Analytics_Page} instance. |
| 37 | 37 | */ |
| 38 | - public function __construct( $settings_page ) { |
|
| 38 | + public function __construct($settings_page) { |
|
| 39 | 39 | |
| 40 | 40 | $this->settings_page = $settings_page; |
| 41 | 41 | |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return array An array of links including those added by the plugin. |
| 52 | 52 | */ |
| 53 | - public function action_links( $links ) { |
|
| 53 | + public function action_links($links) { |
|
| 54 | 54 | |
| 55 | 55 | // Get the menu slug from the page, then prepare the path, hence the url. |
| 56 | 56 | $menu_slug = $this->settings_page->get_menu_slug(); |
| 57 | 57 | $path = "admin.php?page=$menu_slug"; |
| 58 | - $url = get_admin_url( null, $path ); |
|
| 58 | + $url = get_admin_url(null, $path); |
|
| 59 | 59 | |
| 60 | 60 | // Add our own link to the list of links. |
| 61 | 61 | return array_merge( |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | array( |
| 64 | 64 | sprintf( |
| 65 | 65 | '<a href="%1$s">%2$s</a>', |
| 66 | - esc_url( $url ), |
|
| 67 | - esc_html__( 'Analytics Settings', 'wordlift' ) |
|
| 66 | + esc_url($url), |
|
| 67 | + esc_html__('Analytics Settings', 'wordlift') |
|
| 68 | 68 | ), |
| 69 | 69 | ) |
| 70 | 70 | ); |
@@ -25,24 +25,24 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function wl_transition_post_status( $new_status, $old_status, $post ) { |
| 27 | 27 | |
| 28 | - // transition from *published* to any other status: delete the post. |
|
| 29 | - if ( 'publish' === $old_status && 'publish' !== $new_status ) { |
|
| 30 | - // Delete the post from the triple store. |
|
| 31 | - rl_delete_post( $post ); |
|
| 32 | - |
|
| 33 | - // Remove all relation instances for the current post from `wl_relation_instances`. |
|
| 34 | - wl_core_delete_relation_instances( $post->ID ); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - // when a post is published, then all the referenced entities must be published. |
|
| 38 | - if ( 'publish' !== $old_status && 'publish' === $new_status |
|
| 39 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
| 40 | - && apply_filters( 'wl_feature__enable__entity-auto-publish', true ) ) { |
|
| 41 | - |
|
| 42 | - foreach ( wl_core_get_related_entity_ids( $post->ID ) as $entity_id ) { |
|
| 43 | - wl_update_post_status( $entity_id, 'publish' ); |
|
| 44 | - } |
|
| 45 | - } |
|
| 28 | + // transition from *published* to any other status: delete the post. |
|
| 29 | + if ( 'publish' === $old_status && 'publish' !== $new_status ) { |
|
| 30 | + // Delete the post from the triple store. |
|
| 31 | + rl_delete_post( $post ); |
|
| 32 | + |
|
| 33 | + // Remove all relation instances for the current post from `wl_relation_instances`. |
|
| 34 | + wl_core_delete_relation_instances( $post->ID ); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + // when a post is published, then all the referenced entities must be published. |
|
| 38 | + if ( 'publish' !== $old_status && 'publish' === $new_status |
|
| 39 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
| 40 | + && apply_filters( 'wl_feature__enable__entity-auto-publish', true ) ) { |
|
| 41 | + |
|
| 42 | + foreach ( wl_core_get_related_entity_ids( $post->ID ) as $entity_id ) { |
|
| 43 | + wl_update_post_status( $entity_id, 'publish' ); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // hook save events. |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | function rl_delete_post( $post ) { |
| 57 | 57 | |
| 58 | - $post_id = ( is_numeric( $post ) ? $post : $post->ID ); |
|
| 58 | + $post_id = ( is_numeric( $post ) ? $post : $post->ID ); |
|
| 59 | 59 | |
| 60 | - // Remove the post. |
|
| 61 | - do_action( 'wl_legacy_linked_data__remove', $post_id ); |
|
| 60 | + // Remove the post. |
|
| 61 | + do_action( 'wl_legacy_linked_data__remove', $post_id ); |
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
@@ -70,32 +70,32 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | function wl_update_post_status( $post_id, $status ) { |
| 72 | 72 | |
| 73 | - global $wpdb; |
|
| 73 | + global $wpdb; |
|
| 74 | 74 | |
| 75 | - $post = get_post( $post_id ); |
|
| 76 | - if ( ! $post ) { |
|
| 77 | - return; |
|
| 78 | - } |
|
| 75 | + $post = get_post( $post_id ); |
|
| 76 | + if ( ! $post ) { |
|
| 77 | + return; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - if ( $status === $post->post_status ) { |
|
| 81 | - return; |
|
| 82 | - } |
|
| 80 | + if ( $status === $post->post_status ) { |
|
| 81 | + return; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - $wpdb->update( $wpdb->posts, array( 'post_status' => $status ), array( 'ID' => $post->ID ) ); |
|
| 84 | + $wpdb->update( $wpdb->posts, array( 'post_status' => $status ), array( 'ID' => $post->ID ) ); |
|
| 85 | 85 | |
| 86 | - clean_post_cache( $post->ID ); |
|
| 86 | + clean_post_cache( $post->ID ); |
|
| 87 | 87 | |
| 88 | - $old_status = $post->post_status; |
|
| 89 | - $post->post_status = $status; |
|
| 88 | + $old_status = $post->post_status; |
|
| 89 | + $post->post_status = $status; |
|
| 90 | 90 | |
| 91 | - wp_transition_post_status( $status, $old_status, $post ); |
|
| 91 | + wp_transition_post_status( $status, $old_status, $post ); |
|
| 92 | 92 | |
| 93 | - /** This action is documented in wp-includes/post.php */ |
|
| 94 | - do_action( 'edit_post', $post->ID, $post ); |
|
| 95 | - /** This action is documented in wp-includes/post.php */ |
|
| 96 | - do_action( "save_post_{$post->post_type}", $post->ID, $post, true ); |
|
| 97 | - /** This action is documented in wp-includes/post.php */ |
|
| 98 | - do_action( 'wl_linked_data_save_post', $post->ID ); |
|
| 99 | - /** This action is documented in wp-includes/post.php */ |
|
| 100 | - do_action( 'wp_insert_post', $post->ID, $post, true ); |
|
| 93 | + /** This action is documented in wp-includes/post.php */ |
|
| 94 | + do_action( 'edit_post', $post->ID, $post ); |
|
| 95 | + /** This action is documented in wp-includes/post.php */ |
|
| 96 | + do_action( "save_post_{$post->post_type}", $post->ID, $post, true ); |
|
| 97 | + /** This action is documented in wp-includes/post.php */ |
|
| 98 | + do_action( 'wl_linked_data_save_post', $post->ID ); |
|
| 99 | + /** This action is documented in wp-includes/post.php */ |
|
| 100 | + do_action( 'wp_insert_post', $post->ID, $post, true ); |
|
| 101 | 101 | } |
@@ -23,42 +23,42 @@ discard block |
||
| 23 | 23 | * @param string $old_status The old post status |
| 24 | 24 | * @param array $post An array with the post data |
| 25 | 25 | */ |
| 26 | -function wl_transition_post_status( $new_status, $old_status, $post ) { |
|
| 26 | +function wl_transition_post_status($new_status, $old_status, $post) { |
|
| 27 | 27 | |
| 28 | 28 | // transition from *published* to any other status: delete the post. |
| 29 | - if ( 'publish' === $old_status && 'publish' !== $new_status ) { |
|
| 29 | + if ('publish' === $old_status && 'publish' !== $new_status) { |
|
| 30 | 30 | // Delete the post from the triple store. |
| 31 | - rl_delete_post( $post ); |
|
| 31 | + rl_delete_post($post); |
|
| 32 | 32 | |
| 33 | 33 | // Remove all relation instances for the current post from `wl_relation_instances`. |
| 34 | - wl_core_delete_relation_instances( $post->ID ); |
|
| 34 | + wl_core_delete_relation_instances($post->ID); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | // when a post is published, then all the referenced entities must be published. |
| 38 | - if ( 'publish' !== $old_status && 'publish' === $new_status |
|
| 38 | + if ('publish' !== $old_status && 'publish' === $new_status |
|
| 39 | 39 | // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
| 40 | - && apply_filters( 'wl_feature__enable__entity-auto-publish', true ) ) { |
|
| 40 | + && apply_filters('wl_feature__enable__entity-auto-publish', true)) { |
|
| 41 | 41 | |
| 42 | - foreach ( wl_core_get_related_entity_ids( $post->ID ) as $entity_id ) { |
|
| 43 | - wl_update_post_status( $entity_id, 'publish' ); |
|
| 42 | + foreach (wl_core_get_related_entity_ids($post->ID) as $entity_id) { |
|
| 43 | + wl_update_post_status($entity_id, 'publish'); |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // hook save events. |
| 49 | -add_action( 'transition_post_status', 'wl_transition_post_status', 10, 3 ); |
|
| 49 | +add_action('transition_post_status', 'wl_transition_post_status', 10, 3); |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Delete the specified post from the triple store. |
| 53 | 53 | * |
| 54 | 54 | * @param array|int $post An array of post data |
| 55 | 55 | */ |
| 56 | -function rl_delete_post( $post ) { |
|
| 56 | +function rl_delete_post($post) { |
|
| 57 | 57 | |
| 58 | - $post_id = ( is_numeric( $post ) ? $post : $post->ID ); |
|
| 58 | + $post_id = (is_numeric($post) ? $post : $post->ID); |
|
| 59 | 59 | |
| 60 | 60 | // Remove the post. |
| 61 | - do_action( 'wl_legacy_linked_data__remove', $post_id ); |
|
| 61 | + do_action('wl_legacy_linked_data__remove', $post_id); |
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
@@ -68,34 +68,34 @@ discard block |
||
| 68 | 68 | * @param int $post_id The post ID |
| 69 | 69 | * @param string $status The new status |
| 70 | 70 | */ |
| 71 | -function wl_update_post_status( $post_id, $status ) { |
|
| 71 | +function wl_update_post_status($post_id, $status) { |
|
| 72 | 72 | |
| 73 | 73 | global $wpdb; |
| 74 | 74 | |
| 75 | - $post = get_post( $post_id ); |
|
| 76 | - if ( ! $post ) { |
|
| 75 | + $post = get_post($post_id); |
|
| 76 | + if ( ! $post) { |
|
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if ( $status === $post->post_status ) { |
|
| 80 | + if ($status === $post->post_status) { |
|
| 81 | 81 | return; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - $wpdb->update( $wpdb->posts, array( 'post_status' => $status ), array( 'ID' => $post->ID ) ); |
|
| 84 | + $wpdb->update($wpdb->posts, array('post_status' => $status), array('ID' => $post->ID)); |
|
| 85 | 85 | |
| 86 | - clean_post_cache( $post->ID ); |
|
| 86 | + clean_post_cache($post->ID); |
|
| 87 | 87 | |
| 88 | 88 | $old_status = $post->post_status; |
| 89 | 89 | $post->post_status = $status; |
| 90 | 90 | |
| 91 | - wp_transition_post_status( $status, $old_status, $post ); |
|
| 91 | + wp_transition_post_status($status, $old_status, $post); |
|
| 92 | 92 | |
| 93 | 93 | /** This action is documented in wp-includes/post.php */ |
| 94 | - do_action( 'edit_post', $post->ID, $post ); |
|
| 94 | + do_action('edit_post', $post->ID, $post); |
|
| 95 | 95 | /** This action is documented in wp-includes/post.php */ |
| 96 | - do_action( "save_post_{$post->post_type}", $post->ID, $post, true ); |
|
| 96 | + do_action("save_post_{$post->post_type}", $post->ID, $post, true); |
|
| 97 | 97 | /** This action is documented in wp-includes/post.php */ |
| 98 | - do_action( 'wl_linked_data_save_post', $post->ID ); |
|
| 98 | + do_action('wl_linked_data_save_post', $post->ID); |
|
| 99 | 99 | /** This action is documented in wp-includes/post.php */ |
| 100 | - do_action( 'wp_insert_post', $post->ID, $post, true ); |
|
| 100 | + do_action('wp_insert_post', $post->ID, $post, true); |
|
| 101 | 101 | } |