Skip to content

Commit

Permalink
Build docs++
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafauysal committed Feb 20, 2024
1 parent 6aee6c4 commit cda9bbf
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 32 deletions.
35 changes: 35 additions & 0 deletions docs/classes_AdvancedCache.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ <h1 class="page-title">Source: classes/AdvancedCache.php</h1>
add_filter( 'powered_cache_page_cache_enable', array( $this, 'maybe_caching_disabled' ) );
add_filter( 'powered_cache_mod_rewrite', array( $this, 'maybe_disable_mod_rewrite' ), 99 );
add_action( 'wp_update_site', array( $this, 'purge_on_site_update' ), 10, 2 );
add_action( 'create_term', array( $this, 'purge_on_term_change' ), 10, 3 );
add_action( 'edit_term', array( $this, 'purge_on_term_change' ), 10, 3 );
add_action( 'delete_term', array( $this, 'purge_on_term_change' ), 10, 3 );
}

/**
Expand Down Expand Up @@ -699,6 +702,38 @@ <h1 class="page-title">Source: classes/AdvancedCache.php</h1>
}


/**
* Purge cache when term change
*
* @param int $term_id Term ID
* @param int $tt_id Term Taxonomy ID
* @param string $taxonomy Taxonomy
*
* @since 3.4.2
*/
public function purge_on_term_change( $term_id, $tt_id, $taxonomy ) {
$term_taxonomy = get_taxonomy( $taxonomy );

if ( ! $term_taxonomy->public ) {
return;
}

$term_url = get_term_link( $term_id, $taxonomy );

if ( ! is_wp_error( $term_url ) ) {
if ( $this->settings['async_cache_cleaning'] ) {
$this->cache_purger->push_to_queue(
[
'call' => 'delete_page_cache',
'urls' => $term_url,
]
);
$this->cache_purger->save()->dispatch();
} else {
delete_page_cache( $term_url );
}
}
}

}

Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_accepted_query_strings.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line609">line 609</a>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line612">line 612</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_advanced_cache_purge_post.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line268">line 268</a>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line271">line 271</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_advanced_cache_purge_urls.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line238">line 238</a>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line241">line 241</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_cache_query_strings.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line540">line 540</a>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line543">line 543</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_cdn_addresses.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line935">line 935</a>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line979">line 979</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_flushed.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h4 class="name" id="powered_cache_flushed">do_action( 'powered_cache_flushed' )

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line1000">line 1000</a>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line1044">line 1044</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_get_url_dir.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line900">line 900</a>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line944">line 944</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_ignored_query_strings.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line622">line 622</a>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line625">line 625</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_known_headers.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line1175">line 1175</a>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line1219">line 1219</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_log_destination.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line1057">line 1057</a>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line1101">line 1101</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_log_message.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line1027">line 1027</a>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line1071">line 1071</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_log_message_type.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line1039">line 1039</a>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line1083">line 1083</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_post_related_urls.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line831">line 831</a>
<a href="utils.php.html">utils.php</a>, <a href="utils.php.html#line875">line 875</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_rejected_cookies.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line420">line 420</a>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line423">line 423</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_rejected_uri_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line504">line 504</a>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line507">line 507</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_rejected_user_agents.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line477">line 477</a>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line480">line 480</a>
</li></ul></dd>


Expand Down
2 changes: 1 addition & 1 deletion docs/powered_cache_vary_cookies.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line447">line 447</a>
<a href="classes_AdvancedCache.php.html">classes/AdvancedCache.php</a>, <a href="classes_AdvancedCache.php.html#line450">line 450</a>
</li></ul></dd>


Expand Down
74 changes: 59 additions & 15 deletions docs/utils.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ <h1 class="page-title">Source: utils.php</h1>
// Valid post statuses that require cache purging.
$valid_post_statuses = [ 'publish', 'private', 'trash', 'pending', 'draft' ];
$post_status = get_post_status( $post_id );
$post = get_post( $post_id );

// Post types that should not have their cache purged.
$excluded_post_types = [ 'nav_menu_item', 'revision' ];
Expand All @@ -763,8 +764,9 @@ <h1 class="page-title">Source: utils.php</h1>
// Add REST API URL if applicable.
if ( $rest_api_route ) {
$post_type_object = get_post_type_object( $post_type );
if ( isset( $post_type_object->rest_base ) ) {
$related_urls[] = get_rest_url() . $rest_api_route . '/' . $post_type_object->rest_base . '/' . $post_id . '/';
if ( ! empty( $post_type_object->show_in_rest ) ) {
$post_type_base = $post_type_object->rest_base ? $post_type_object->rest_base : $post_type_object->name;
$related_urls[] = get_rest_url() . $rest_api_route . '/' . $post_type_base . '/' . $post_id . '/';
} elseif ( in_array( $post_type, [ 'post', 'page' ], true ) ) {
$related_urls[] = get_rest_url() . $rest_api_route . '/' . $post_type . 's/' . $post_id . '/';
}
Expand All @@ -788,21 +790,50 @@ <h1 class="page-title">Source: utils.php</h1>
$related_urls[] = $trash_permalink . 'feed/';
}

// Purge categories and tags associated with the post.
$categories = get_the_category( $post_id );
foreach ( $categories as $category ) {
$related_urls[] = get_category_link( $category->term_id );
if ( $rest_api_route ) {
$related_urls[] = get_rest_url() . $rest_api_route . '/categories/' . $category->term_id . '/';
$taxonomies = get_object_taxonomies( get_post_type( $post_id ), 'objects' );

// Purge terms associated with the post.
foreach ( $taxonomies as $taxonomy ) {
// Skip non-public taxonomies.
if ( ! $taxonomy->public ) {
continue;
}

$terms = get_the_terms( $post_id, $taxonomy->name );

if ( empty( $terms ) || is_wp_error( $terms ) ) {
continue;
}
}

$tags = get_the_tags( $post_id );
if ( $tags ) {
foreach ( $tags as $tag ) {
$related_urls[] = get_tag_link( $tag->term_id );
if ( $rest_api_route ) {
$related_urls[] = get_rest_url() . $rest_api_route . '/tags/' . $tag->term_id . '/';
foreach ( $terms as $term ) {
$term_url = get_term_link( $term->slug, $taxonomy->name );
if ( ! is_wp_error( $term_url ) ) {
$related_urls[] = $term_url;
if ( $taxonomy->show_in_rest ) {
$taxonomy_base = $taxonomy->rest_base ? $taxonomy->rest_base : $taxonomy->name;
$related_urls[] = rest_url( "{$taxonomy->rest_namespace}/{$taxonomy_base}/{$term->term_id}/" ); // REST API URL for the term
}
}

if ( ! is_taxonomy_hierarchical( $taxonomy->name ) ) {
continue;
}

$ancestors = (array) get_ancestors( $term->term_id, $taxonomy->name );
foreach ( $ancestors as $ancestor ) {
$ancestor_object = get_term( $ancestor, $taxonomy->name );
if ( ! is_a( $ancestor, '\WP_Term' ) ) {
continue;
}

$ancestor_term_url = get_term_link( $ancestor_object->slug, $taxonomy->name );
if ( ! is_wp_error( $ancestor_term_url ) ) {
$related_urls[] = $ancestor_term_url;
if ( $taxonomy->show_in_rest ) {
$taxonomy_base = $taxonomy->rest_base ? $taxonomy->rest_base : $taxonomy->name;
$related_urls[] = rest_url( "{$taxonomy->rest_namespace}/{$taxonomy_base}/{$ancestor_object->term_id}/" ); // REST API URL for the ancestor term
}
}
}
}
}
Expand Down Expand Up @@ -834,6 +865,19 @@ <h1 class="page-title">Source: utils.php</h1>
$related_urls[] = get_post_type_archive_feed_link( $post_type );
}

$post_date = strtotime( $post->post_date );

if ( $post_date ) {
// Generate the date archive URLs
$year = gmdate( 'Y', $post_date );
$month = gmdate( 'm', $post_date );
$day = gmdate( 'd', $post_date );

$related_urls[] = get_year_link( $year );
$related_urls[] = get_month_link( $year, $month );
$related_urls[] = get_day_link( $year, $month, $day );
}

// Always purge the home page.
$related_urls[] = home_url( '/' );

Expand Down

0 comments on commit cda9bbf

Please sign in to comment.