Skip to content

Commit

Permalink
Fixed activation, layout, and PHP 8.2 deprecation.
Browse files Browse the repository at this point in the history
  • Loading branch information
sybrew committed Sep 29, 2022
1 parent ce4cf3a commit 66ddad5
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 89 deletions.
2 changes: 1 addition & 1 deletion bootstrap/upgrader.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public function _parse() {
* @param \stdClass $upgrade The upgrade iterator object.
* @yield array { $member => $version }
*/
private function yield_runs( \$upgrade ) {
private function yield_runs( $upgrade ) {
foreach ( $upgrade as $member => $versions ) {
foreach ( $versions as $version => $callbacks ) {
foreach ( $callbacks as $callback ) {
Expand Down
61 changes: 35 additions & 26 deletions extensions/free/transport/trunk/inc/classes/admin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ final class Admin {
* @since 1.0.0
* @var string The validation nonce name.
*/
protected $ajax_nonce_action;
private $ajax_nonce_action;

/**
* @since 1.0.0
* @var string Page hook name
*/
protected $transport_menu_page_hook;
private $transport_menu_page_hook;

/**
* @since 1.0.0
* @var string Page ID/Slug
*/
protected $transport_page_slug;
private $transport_page_slug;

/**
* Constructor, initializes WordPress actions.
Expand All @@ -89,7 +89,37 @@ private function construct() {

$this->ajax_nonce_action = 'tsfem_e_transport_ajax';

$this->importers = [
$this->transport_page_slug = 'theseoframework-transport';

/**
* Set error notice option.
*
* @see trait TSF_Extension_Manager\Error
*/
$this->error_notice_option = 'tsfem_e_transport_error_notice_option';

// Nothing to do here...
if ( \tsf()->is_headless['settings'] ) return;

// Initialize menu links
\add_action( 'admin_menu', [ $this, '_init_menu' ] );

// Initialize Transport page actions.
\add_action( 'admin_init', [ $this, '_load_transport_admin_actions' ] );

// Update POST listener.
\add_action( 'wp_ajax_tsfem_e_transport', [ $this, '_wp_ajax_transport' ] );
}

/**
* Returns a list of supported importers.
*
* @since 1.0.0
*
* @return array A list of supported importers.
*/
private function get_importers() {
return [
'' => [
'title' => sprintf(
'— %s —',
Expand Down Expand Up @@ -219,27 +249,6 @@ private function construct() {
// 'title' => 'All In One SEO',
// ],
];

$this->transport_page_slug = 'theseoframework-transport';

/**
* Set error notice option.
*
* @see trait TSF_Extension_Manager\Error
*/
$this->error_notice_option = 'tsfem_e_transport_error_notice_option';

// Nothing to do here...
if ( \tsf()->is_headless['settings'] ) return;

// Initialize menu links
\add_action( 'admin_menu', [ $this, '_init_menu' ] );

// Initialize Transport page actions.
\add_action( 'admin_init', [ $this, '_load_transport_admin_actions' ] );

// Update POST listener.
\add_action( 'wp_ajax_tsfem_e_transport', [ $this, '_wp_ajax_transport' ] );
}

/**
Expand Down Expand Up @@ -301,7 +310,7 @@ public function _wp_ajax_transport() {

switch ( $_REQUEST['handle'] ?? null ) :
case 'import':
( new Handler )->_import( $this->importers );
( new Handler )->_import( $this->get_importers() );
break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,11 @@ protected function _rank_math_term_meta_transmuter( $data, &$actions, &$results
}

if ( isset( $data['to_data']['sanitizers'][ $from ] ) ) {
$_set_value = \call_user_func_array(
$data['to_data']['sanitizers'][ $from ],
[
$_set_value,
$data['item_id'],
$this->type,
[ $from_table, $from_index ],
[ $to_table, $to_index ],
]
);
$_pre_sanitize_value = $_set_value;

$_set_value = \call_user_func( $data['to_data']['sanitizers'][ $from ], $_set_value );

$results['sanitized'] += (int) ( $_pre_sanitize_value !== $set_value );
}

if ( ! \in_array( $_set_value, $this->useless_data, true ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,11 @@ protected function _wpseo_term_meta_transmuter( $data, &$actions, &$results ) {
}

if ( isset( $data['to_data']['sanitizers'][ $from ] ) ) {
$_set_value = \call_user_func_array(
$data['to_data']['sanitizers'][ $from ],
[
$_set_value,
$data['item_id'],
$this->type,
[ $from_table, $from_index ],
[ $to_table, $to_index ],
]
);
$_pre_sanitize_value = $_set_value;

$_set_value = \call_user_func( $data['to_data']['sanitizers'][ $from ], $_set_value );

$results['sanitized'] += (int) ( $_pre_sanitize_value !== $set_value );
}

if ( ! \in_array( $_set_value, $this->useless_data, true ) ) {
Expand Down
14 changes: 7 additions & 7 deletions extensions/free/transport/trunk/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ The importer keeps track of how many database items are found per data type; it

The logger will display in real-time the progress of all data transactions.

Because webbrowsers become slow at about 32 000 characters, the logger trims chunks of old log data to stay beneath that number.
You can hit "Copy log" to grab what's in the logger.
Because webbrowsers become slow at about 32 000 characters (18 book pages), the logger trims chunks of old log data to stay beneath that number.
You can hit "Copy log" to grab what's present in the logger.

If there's an issue, feel free to send us a [support email](https://theseoframework.com/support/) with the log attached.

Expand All @@ -65,24 +65,24 @@ Yes.

#### Really?

Yes. Transport can irreversibly alter and irretrievably delete metadata.
Yes. Transport will irreversibly alter and irretrievably delete metadata; both are intended features.

We recommend transporting only when you're certain you want to stay with The SEO Framework.
Otherwise, you should keep a backup ready in case you want to go back (we cannot comprehend why anyone would, though).

### What data is transformed?

All titles and descriptions pass through the transformer. This transformer takes syntax, such as `%archive_title%`, and transforms those accordingly.
All titles and descriptions pass through the transformer. This transformer takes syntax, such as `%archive_title%`, and transforms those as the plugin you're migrating from would.

After transformation, stray separators and spaces will be trimmed from either side of the title or description.
After transformation, repeating separators will coalesced (`text | | | text` becomes `text | text`), and stray separators and spaces will be trimmed from either side of the title or description.

| Syntax | Becomes |
|:----------------------- |:------------------------------------------------------------------------ |
| `archive_title` | The term title |
| `author_first_name` | The post author first name |
| `author_last_name` | The post author last name |
| `caption` | The post excerpt |
| `category` | All post category names, or the term title |
| `category` | All post category names or the term title |
| `category_description` | The term description |
| `category_title` | The term title |
| `currentdate` | [tsfep-gimmick type="date" format="F j, Y"] |
Expand All @@ -103,7 +103,7 @@ After transformation, stray separators and spaces will be trimmed from either si
| `post_day` | The post publishing day (e.g., [tsfep-gimmick type="date" format="j"]) |
| `pt_plural` | The current post type plural name (e.g., Posts) |
| `pt_single` | The current post type singular name (e.g., Post) |
| `sep` | The title separator (·, |, >, etc.) |
| `sep` | The title separator (`·`, `|`, `>`, etc.) |
| `sitedesc` | The blog description |
| `sitename` | The blog name |
| `tag` | All post tag names, or the term title |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
// phpcs:ignore, WordPress.Security.EscapeOutput.OutputNotEscaped -- tsf()->convert_markdown escapes.
tsf()->convert_markdown(
sprintf(
/* translators: %s = URL to backup documentation */
esc_html__( 'This importer updates index keys in the meta databases of this WordPress installation. **Old data will be deleted** and some data may be transformed irreversibly. Although careful consideration was made, transaction errors can occur where **data can be lost permanently**. The Transport extension actively logs all transactions on your screen and will halt transportation on failure. Still, **always make a backup before importing**. [Learn about WordPress backups](%s).', 'the-seo-framework-extension-manager' ),
/* translators: %s = URL to backup documentation. Asterisks are markdown! */
esc_html__( 'The importer updates index keys in the database of this WordPress installation. **Old data will be deleted** and some data will be transformed. The Transport extension actively logs all transactions on your screen and will halt transportation on failure. **Always make a backup before importing** in case you need to undo the transport. [Learn about WordPress backups](%s).', 'the-seo-framework-extension-manager' ),
esc_url( _x(
'https://wordpress.org/support/article/wordpress-backups/',
'backup documentation',
Expand All @@ -42,7 +42,7 @@
$_importer_options = '';
$_selected = true;
$_available = true;
foreach ( $this->importers as $importer => $data ) {
foreach ( $this->get_importers() as $importer => $data ) {
$_importer_options .= vsprintf(
'<option value="%s" %s %s>%s</option>',
[
Expand Down
6 changes: 6 additions & 0 deletions extensions/premium/local/trunk/inc/classes/settings.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ final class Settings {
*/
protected $slug = '';

/**
* @since 1.0.0
* @var array The settings form architectural arguments.
*/
protected $form_args = [];

/**
* Initializes and outputs Settings page.
*
Expand Down
8 changes: 3 additions & 5 deletions extensions/premium/local/trunk/views/layout/general/top.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
?>
</h1></header>
</div>
<div class="tsfem-top-actions tsfem-flex tsfem-flex-row">
<?php
<div class="tsfem-top-actions tsfem-flex tsfem-flex-row"><?=
// phpcs:ignore, WordPress.Security.EscapeOutput -- Already escaped.
echo $this->get_test_button(), $this->get_form()->_form_button( 'submit', __( 'Save', 'the-seo-framework-extension-manager' ), 'get' );
?>
</div>
$this->get_test_button(), $this->get_form()->_form_button( 'submit', __( 'Save', 'the-seo-framework-extension-manager' ), 'get' )
?></div>
<?php
29 changes: 17 additions & 12 deletions inc/classes/schemapacker.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ final class SchemaPacker {
*/
private $output;

/**
* @since 1.3.0
* @var array $registered_conditions The registered conditions to handle.
*/
private $registered_conditions;

/**
* Constructor. Sets up class main variables.
*
Expand Down Expand Up @@ -362,7 +368,7 @@ private function get_value( $key, $schema ) {
$value = $this->escape( $value, $schema->_handlers->_escape );

if ( isset( $schema->_handlers->_condition ) ) {
$this->condition[ $key ] = [];
$this->registered_conditions[ $key ] = [];

$value = $this->condition( $key, $value, $schema->_handlers->_condition );
}
Expand Down Expand Up @@ -535,19 +541,18 @@ private function escape( $value, $how ) {
*/
private function get_condition( $key ) {

if ( empty( $this->condition[ $key ] ) ) {
unset( $this->condition[ $key ] );
if ( empty( $this->registered_conditions[ $key ] ) ) {
unset( $this->registered_conditions[ $key ] );
return -1;
}

$c = $this->condition[ $key ];
unset( $this->condition[ $key ] );

$kill_this = $kill_sub = $kill_pack = 0;

foreach ( $c as $v ) {
// Write to variables. TODO use array_flip/fill or eqv, which are safer?
// $this->registered_conditions[ $key ] = [ 'kill_pack', 'kill_sub', 'kill_this' ];
foreach ( $this->registered_conditions[ $key ] as $v )
${$v} = 1;
}

unset( $this->registered_conditions[ $key ] );

// Returns in order of impact.
if ( $kill_pack )
Expand Down Expand Up @@ -579,9 +584,9 @@ private function get_condition( $key ) {
private function condition( $key, $value, $what ) {

if ( \is_array( $what ) && \count( $what ) > 1 ) {
foreach ( $what as $w ) {
foreach ( $what as $w )
$value = $this->condition( $key, $value, $w );
}

return $value;
}

Expand Down Expand Up @@ -674,7 +679,7 @@ private function condition( $key, $value, $what ) {
case 'kill_this':
case 'kill_sub':
case 'kill_pack':
$this->condition[ $key ][] = $c->_do;
$this->registered_conditions[ $key ][] = $c->_do;
return null;

case 'set':
Expand Down
4 changes: 2 additions & 2 deletions inc/traits/core/ui.trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ final public function panes_wrap() {
* @since 1.5.0
*/
final public function connect_wrap() {
echo '<main class=tsfem-connect-wrap>';
echo '<div class=tsfem-panes-super-wrap><main class=tsfem-connect-wrap>';
\do_action( 'tsfem_content' );
echo '</main>';
echo '</main></div>';
}

/**
Expand Down
8 changes: 2 additions & 6 deletions lib/css/tsfem-ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,10 @@ body.tsfem.rtl .wrap {

#tsfem-top-wrap {
margin: 0 auto;
padding: 0 1.2vw;
padding: 1em 1.2vw;
max-width: 1240px;
}

#tsfem-top-wrap > * {
padding: 1em 0;
}

/* "padding: 0 0 1.4%" Edge/Firefox inline margins issue */
/* "margin: 0 1.4%;" Edge/Firefox inline margins issue */
.tsfem-footer-wrap {
Expand Down Expand Up @@ -695,7 +691,7 @@ body.rtl .tsfem-button-loading:after {
width: 100%;
max-width: 690px;
padding: 1em 1.5em;
margin: 0 auto 1.2vw;
margin-bottom: 1.2vw;
box-sizing: border-box;
background: #fff;
border: 1px solid #ccd0d4;
Expand Down
2 changes: 1 addition & 1 deletion lib/css/tsfem-ui.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Please refer to [the installation instructions on our website](https://kb.theseo
* TODO Use `<use>` like on TSF site for improved painting performance?
* Introduced a new API alias for `tsf_extension_manager()`: `tsfem()`.
* With this update we hit a new milestone: 2 million characters of amazing code.
* The plugin and its extensions now support PHP 8.2 flawlessly.
TODO POT file. (also update related github)

TODO readme: Add pictures, create share logo,
Expand Down
2 changes: 1 addition & 1 deletion the-seo-framework-extension-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: The SEO Framework - Extension Manager
* Plugin URI: https://theseoframework.com/extension-manager/
* Description: Add more powerful SEO features to The SEO Framework. Right from your WordPress dashboard.
* Version: 2.6.0-beta-4
* Version: 2.6.0-beta-5
* Author: The SEO Framework Team
* Author URI: https://theseoframework.com/
* License: GPLv3
Expand Down
11 changes: 6 additions & 5 deletions views/layout/extension/top.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
?>
</h1></header>
</div>
<div class="tsfem-top-actions tsfem-flex tsfem-flex-row">
<?php
<?php
/* TODO
<div class="tsfem-top-actions tsfem-flex tsfem-flex-row"><?=
// phpcs:ignore, WordPress.Security.EscapeOutput.OutputNotEscaped -- get_save_all_button() escapes.
echo $this->get_save_all_button();
?>
</div>
$this->get_save_all_button();
?></div>
<?php
*/

0 comments on commit 66ddad5

Please sign in to comment.