Skip to content

Commit

Permalink
Merge branch 'feature/phpstan' into fix/phpstan-7-4
Browse files Browse the repository at this point in the history
  • Loading branch information
Camwyn committed Nov 14, 2023
2 parents 680b0ec + b462e39 commit ae81234
Show file tree
Hide file tree
Showing 12 changed files with 272 additions and 29 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
matrix:
phpVersion: [
"7.4",
#"8.0",
#"8.1",
#"8.2",
#"8.3",
"8.0",
"8.1",
"8.2",
"8.3",
]
runs-on: ubuntu-20.04
steps:
Expand Down
28 changes: 14 additions & 14 deletions lang/tribe-common.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# This file is distributed under the GPLv2 or later.
msgid ""
msgstr ""
"Project-Id-Version: Tribe Common 5.1.12\n"
"Project-Id-Version: Tribe Common 5.1.14\n"
"Report-Msgid-Bugs-To: https://evnt.is/191x\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2023-10-30T10:01:37-07:00\n"
"PO-Revision-Date: 2023-10-30 17:01\n"
"POT-Creation-Date: 2023-11-13T06:22:37-08:00\n"
"PO-Revision-Date: 2023-11-13 14:22\n"
"X-Generator: WP-CLI 2.7.1\n"
"X-Domain: tribe-common\n"

Expand Down Expand Up @@ -1536,15 +1536,15 @@ msgid "Trusted to power learning programs for major universities, startups, entr
msgstr ""

#: src/Tribe/App_Shop.php:322
msgid "Foundational favorites: iThemes Security and Developer Toolkit."
msgid "Security, backups, and management — that’s Solid Suite."
msgstr ""

#: src/Tribe/App_Shop.php:324
msgid "Add Security"
msgstr ""

#: src/Tribe/App_Shop.php:325
msgid "iThemes Security, the WordPress security plugin that’s easy to use. Built with performance in mind."
msgid "SolidWP, the seriously solid foundation your WordPress site needs. Built with performance in mind."
msgstr ""

#: src/Tribe/App_Shop.php:330
Expand Down Expand Up @@ -1846,35 +1846,35 @@ msgctxt "extension disallowed"
msgid "This extension has been programmatically disallowed. The most common reason is due to another The Events Calendar plugin having absorbed or replaced this extension's functionality. This extension plugin has been deactivated, and you should likely delete it."
msgstr ""

#: src/Tribe/Field.php:253
#: src/Tribe/Field.php:342
msgid "Invalid field type specified"
msgstr ""

#: src/Tribe/Field.php:557
#: src/Tribe/Field.php:646
msgid "No radio options specified"
msgstr ""

#: src/Tribe/Field.php:593
#: src/Tribe/Field.php:682
msgid "No checkbox options specified"
msgstr ""

#: src/Tribe/Field.php:655
#: src/Tribe/Field.php:744
msgid "No select options specified"
msgstr ""

#: src/Tribe/Field.php:757
#: src/Tribe/Field.php:846
msgid "Select Image"
msgstr ""

#: src/Tribe/Field.php:758
#: src/Tribe/Field.php:847
msgid "Remove Image"
msgstr ""

#: src/Tribe/Field.php:762
#: src/Tribe/Field.php:851
msgid "Select an image"
msgstr ""

#: src/Tribe/Field.php:763
#: src/Tribe/Field.php:852
msgid "Use this image"
msgstr ""

Expand Down Expand Up @@ -3686,7 +3686,7 @@ msgstr[1] ""
msgid "Settings saved."
msgstr ""

#: src/Tribe/Settings_Tab.php:225
#: src/Tribe/Settings_Tab.php:250
msgid "There are no fields set up for this tab yet."
msgstr ""

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tribe-common",
"version": "5.1.13",
"version": "5.1.14",
"repository": "git@github.com:the-events-calendar/tribe-common.git",
"_resourcepath": "src/resources",
"_domainPath": "lang",
Expand Down
4 changes: 3 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
== Changelog ==

= [TBD] TBD =
= [5.1.14] 2023-11-13 =

* Fix - Resolved several `Deprecated: Creation of dynamic property` warnings on: `\Tribe__Field::$allow_clear, $type, $class, $label, $label_attributes, $error, $tooltip, $size, $html, $options, $value, $conditional, $placeholder, $display_callback, $if_empty, $can_be_empty, $clear_after, $tooltip_first` and `\Tribe__Settings_Tab::$priority, public $fields, $show_save, $display_callback, $network_admin` [BTRIA-2088]
* Language - 2 new strings added, 9 updated, 1 fuzzied, and 2 obsoleted.

= [5.1.13.1] 2023-11-10 =

Expand All @@ -20,6 +21,7 @@

= [5.1.11] 2023-10-19 =

* Tweak - Changed scope of the Tribe__Editor__Blocks__Abstract::$namespace property to protected. [TEC-4792]
* Fix - AM/PM time formats `g:i A` and `g:i a` are now respected for the French locale. [TEC-4807]
* Tweak - Pass the appropriate arguments to telemetry opt-ins.
* Language - 0 new strings added, 0 updated, 1 fuzzied, and 0 obsoleted
Expand Down
128 changes: 128 additions & 0 deletions src/Common/Editor/Full_Site/Template_Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace TEC\Common\Editor\Full_Site;

use InvalidArgumentException;
use WP_Block_Template;
use WP_Post;
use WP_Query;

/**
* Class Template_Utils.
*
Expand Down Expand Up @@ -85,4 +90,127 @@ public static function inject_theme_attribute_in_content( $template_content ) {

return $template_content;
}

/**
* Fetch a WP_Block_Template by the post_name and terms field.
*
* @since 5.1.14
*
* @param string $post_name The post_name field to search by.
* @param string $terms The terms field to search by, default to 'tec'.
*
* @return WP_Block_Template|null The newly created WP_Block_Template, or null on failure to locate.
*/
public static function find_block_template_by_post( string $post_name, string $terms = 'tec' ): ?WP_Block_Template {
// Let's see if we have a saved template?
$wp_query_args = [
'post_name__in' => [ $post_name ],
'post_type' => 'wp_template',
'post_status' => [ 'auto-draft', 'draft', 'publish', 'trash' ],
'posts_per_page' => 1,
'no_found_rows' => true,
'tax_query' => [
[
'taxonomy' => 'wp_theme',
'field' => 'name',
'terms' => $terms,
],
],
];
$template_query = new WP_Query( $wp_query_args );
$posts = $template_query->posts;

// If empty, our Block Template has not been created in `wp_posts` yet.
if ( empty( $posts ) ) {
return null;
}

$post = $posts[0] ?? null;

// Validate our query result.
if ( ! $post instanceof WP_Post ) {
do_action( 'tribe_log', 'error',
'Failed locating our Post for the Block Template', [
'method' => __METHOD__,
'post_name' => $post_name,
'terms' => $terms
] );

// Might as well bail, avoid errors below.
return null;
}

return self::hydrate_block_template_by_post( $post );
}

/**
* Create a post for the wp_theme and return the hydrated WP_Block_Template.
*
* @since 5.1.14
*
* @param array $post_array Post array for insert.
*
* @return WP_Block_Template|null The newly created WP_Block_Template, or null on error.
* @throws InvalidArgumentException
*/
public static function save_block_template( $post_array ): ?WP_Block_Template {
if ( empty( $post_array['post_name'] ) ) {
throw new InvalidArgumentException( "Must have `post_name` parameter to denote this template uniquely." );
}

if ( empty( $post_array['tax_input'] ) ) {
throw new InvalidArgumentException( "Must have `tax_input` parameter to include the term of the `wp_theme` this template is under." );
}

// Merge with default params.
$insert = array_merge( [
'post_type' => 'wp_template',
'post_status' => 'publish',
], $post_array );

// Create this template.
$id = wp_insert_post( $insert );

if ( ! $id ) {
return null;
}

return self::hydrate_block_template_by_post( get_post( $id ) );
}

/**
* Hydrate a WP_Block_Template from a WP_Post object.
*
* @since 5.1.14
*
* @param WP_Post $post The post to hydrate the WP_Block_Template.
*
* @return WP_Block_Template|null The newly created WP_Block_Template, or null if missing required data.
*/
public static function hydrate_block_template_by_post( WP_Post $post ): ?WP_Block_Template {
$terms = get_the_terms( $post, 'wp_theme' );

if ( is_wp_error( $terms ) || empty( $terms ) ) {
return null;
}

// Hydrate our template with the saved data.
$template = new WP_Block_Template();
$template->wp_id = $post->ID;
$template->id = $terms[0]->name . '//' . $post->post_name;
$template->theme = $terms[0]->name;
$template->content = $post->post_content;
$template->slug = $post->post_name;
$template->source = 'custom';
$template->type = 'wp_template';
$template->title = $post->post_title;
$template->description = $post->post_excerpt;
$template->status = $post->post_status;
$template->has_theme_file = false;
$template->is_custom = true;
$template->author = $post->post_author;
$template->modified = $post->post_modified;

return $template;
}
}
6 changes: 3 additions & 3 deletions src/Tribe/Admin/Help_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function admin_body_class( $classes ) {
* Checks if the current page is the Help one
*
* @since 4.5.7
* @since TBD Verifying that the current page is a screen
* @since 5.1.12 Verifying that the current page is a screen
*
* @return bool
*/
Expand All @@ -76,7 +76,7 @@ public function is_current_page() {
/**
* Checks if the current page is the TEC Help one
*
* @since TBD
* @since 5.1.12
*
* @return bool
*/
Expand All @@ -95,7 +95,7 @@ public function is_tec_events_help_page() {
/**
* Checks if the current page is the Tickets Help one
*
* @since TBD
* @since 5.1.12
*
* @return bool
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Tribe/Editor/Blocks/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class Tribe__Editor__Blocks__Abstract
*
* @var string
*/
private $namespace = 'tribe';
protected $namespace = 'tribe';

/**
* Builds the name of the Block
Expand All @@ -34,7 +34,7 @@ public function name() {
*
* @return string
*/
public function get_namespace() {
public function get_namespace(): string {
return $this->namespace;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tribe/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Tribe__Main {
const OPTIONNAME = 'tribe_events_calendar_options';
const OPTIONNAMENETWORK = 'tribe_events_calendar_network_options';

const VERSION = '5.1.13.1';
const VERSION = '5.1.14';

const FEED_URL = 'https://theeventscalendar.com/feed/';

Expand Down
1 change: 1 addition & 0 deletions tests/_data/classes/Http_API/Http_API_Mock.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

namespace TEC\Common\Tests\Http_API;

use WpOrg\Requests\Cookie\Jar;
use WpOrg\Requests\Response;
use WpOrg\Requests\Response\Headers;
Expand Down
Loading

0 comments on commit ae81234

Please sign in to comment.