Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant return type on insert_parsely_page #443

Merged
merged 7 commits into from
Oct 13, 2021
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions src/class-parsely.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function run(): void {
add_action( 'parsely_bulk_metas_update', array( $this, 'bulk_update_posts' ) );

// inserting parsely code.
add_action( 'wp_head', array( $this, 'insert_parsely_page' ) );
add_action( 'wp_head', array( $this, 'insert_page_header_metadata' ) );
add_action( 'init', array( $this, 'register_js' ) );

// load_js_api should be called prior to load_js_tracker so the relevant scripts are enqueued in order.
Expand Down Expand Up @@ -770,9 +770,11 @@ public function print_dynamic_tracking_note(): void {
/**
* Actually inserts the code for the <meta name='parsely-page'> parameter within the <head></head> tag.
*
* @return string|null|array
* @since 3.0.0
*
* @return void
*/
public function insert_parsely_page() {
public function insert_page_header_metadata(): void {
/**
* Filters whether the Parse.ly meta tags should be inserted in the page.
*
Expand All @@ -789,18 +791,18 @@ public function insert_parsely_page() {
$parsely_options = $this->get_options();

if (
$this->api_key_is_missing() ||
$this->api_key_is_missing() ||

// Chosen not to track logged-in users.
( ! $parsely_options['track_authenticated_users'] && $this->parsely_is_user_logged_in() ) ||
// Chosen not to track logged-in users.
( ! $parsely_options['track_authenticated_users'] && $this->parsely_is_user_logged_in() ) ||

// 404 pages are not tracked.
is_404() ||
// 404 pages are not tracked.
is_404() ||

// Search pages are not tracked.
is_search()
// Search pages are not tracked.
is_search()
) {
return '';
return;
}

global $post;
Expand Down Expand Up @@ -851,8 +853,22 @@ public function insert_parsely_page() {
}

echo '<!-- END Parse.ly -->' . "\n\n";
}

return $parsely_page;
GaryJones marked this conversation as resolved.
Show resolved Hide resolved
/**
* Actually inserts the code for the <meta name='parsely-page'> parameter within the <head></head> tag.
pauarge marked this conversation as resolved.
Show resolved Hide resolved
*
* @deprecated 3.0.0
* @see construct_parsely_metadata()
*
* @return array
*/
public function insert_parsely_page(): array {
_deprecated_function( __FUNCTION__, '3.0', 'construct_parsely_metadata()' );
$this->insert_page_header_metadata();

global $post;
return $this->construct_parsely_metadata( $this->get_options(), $post );
}

/**
Expand Down