Skip to content

Commit

Permalink
Add option to remove data on uninstall and code modernization (#175)
Browse files Browse the repository at this point in the history
* Remove Updates class

* Remove autodeactivation of conflicting plugins

* Add delete all data on uninstall option

* Remove deprecations

* Remove deprecation

* Changelog

* Use updated actions

---------

Co-authored-by: xxsimoxx <simone@gieffeedizioni.it>
  • Loading branch information
xxsimoxx and xxsimoxx authored Jul 4, 2024
1 parent b0a84e9 commit 050cc17
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 554 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: setup git config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: Create artifact
run : |
git archive -o classicpress-seo.zip --prefix classicpress-seo/ HEAD
git archive -o classicpress-seo.zip --prefix classicpress-seo/ HEAD
- name: Upload artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: classicpress-seo
path: classicpress-seo.zip
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
####v 2.3.0 / 2024-07-02
* IMPROVED: Add option to remove data on uninstall (in General Settings > Misc)
* REMOVED: Remove automatic deactivation of conflicting plugins (that wasn't working)
* REMOVED: Remove unused Update class
* FIXED: Fix some more PHP deprecations

####v 2.2.2 / 2024-06-20
* FIXED: Fix traits in authors sitemap (#173)

Expand Down
4 changes: 2 additions & 2 deletions classicpress-seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Classic SEO
* Plugin URI: https://github.com/ClassicPress/classicpress-seo
* Description: Classic SEO is the first SEO plugin built specifically to work with ClassicPress. The plugin contains many essential SEO tools to help optimize your website.
* Version: 2.2.2
* Version: 2.3.0
* Author: ClassicPress
* Author URI: https://github.com/ClassicPress
* License: GPL v2 or later
Expand Down Expand Up @@ -34,7 +34,7 @@ class Classic_SEO {
*
* @var string
*/
public $version = '2.2.2';
public $version = '2.3.0';

/**
* Classic SEO database version.
Expand Down
3 changes: 1 addition & 2 deletions includes/admin/class-engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct() {

$runners = [
cpseo()->admin,
cpseo()->admin_assets,
cpseo()->admin_assets,
new Admin_Menu,
new Option_Center,
new Notices,
Expand All @@ -46,7 +46,6 @@ public function __construct() {
new Post_Columns,
new Post_Filters,
new Import_Export,
new Updates,
new Watcher,
];

Expand Down
6 changes: 3 additions & 3 deletions includes/admin/helpers/class-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Classic_SEO\Admin;


use WP_List_Table;
use Classic_SEO\Helpers\Param;

Expand Down Expand Up @@ -52,7 +52,7 @@ protected function get_order() {
* @return string
*/
protected function get_orderby( $default = 'create_date' ) {
return Param::get( 'orderby', $default, FILTER_SANITIZE_STRING );
return Param::get( 'orderby', $default, FILTER_UNSAFE_RAW );
}

/**
Expand All @@ -61,7 +61,7 @@ protected function get_orderby( $default = 'create_date' ) {
* @return bool|string
*/
protected function get_search() {
return Param::request( 's', false, FILTER_SANITIZE_STRING );
return Param::request( 's', false, FILTER_UNSAFE_RAW );
}

/**
Expand Down
10 changes: 0 additions & 10 deletions includes/admin/views/help/developers.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,6 @@

<hr>

<h4><?php esc_html_e( 'Remove all Classic SEO data from the database on uninstall', 'cpseo' ); ?></h4>
<p><?php esc_html_e( 'Filter to remove Classic SEO data from the database', 'cpseo' ); ?></p>

<?php
$code5 = 'add_filter( \'cpseo_clear_data_on_uninstall\', \'__return_true\' )';
?>
<pre><code><?php esc_html_e($code5); ?></code></pre>

<hr>

<h4><?php esc_html_e( 'Add Custom Power Words', 'cpseo' ); ?></h4>
<p><?php esc_html_e( 'Filter to add custom Power Words', 'cpseo' ); ?></p>

Expand Down
31 changes: 0 additions & 31 deletions includes/admin/watcher/class-watcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,10 @@ class Watcher implements Runner {
* Register hooks.
*/
public function hooks() {
$this->action( 'init', 'init' );
$this->action( 'activated_plugin', 'check_activated_plugin' );
$this->action( 'deactivated_plugin', 'check_deactivated_plugin' );
}

/**
* Set/Deactivate conflicting SEO or Sitemap plugins.
*/
public function init() {
if ( isset( $_GET['cpseo_deactivate_seo_plugins'] ) ) {
$this->deactivate_conflicting_plugins( 'seo' );
return;
}

if ( isset( $_GET['cpseo_deactivate_sitemap_plugins'] ) ) {
$this->deactivate_conflicting_plugins( 'sitemap' );
return;
}
}

/**
* Function to run when new plugin is activated.
*/
Expand Down Expand Up @@ -93,21 +77,6 @@ public static function module_changed( $module, $state ) {
self::check_activated_plugin();
}

/**
* Deactivate conflicting plugins.
*
* @param string $type Plugin type.
*/
private function deactivate_conflicting_plugins( $type ) {
foreach ( self::get_conflicting_plugins() as $plugin => $plugin_type ) {
if ( $type === $plugin_type && is_plugin_active( $plugin ) ) {
deactivate_plugins( $plugin );
}
}

wp_redirect( remove_query_arg( "cpseo_deactivate_{$type}_plugins" ) );
}

/**
* Function to set conflict plugin notification.
*
Expand Down
1 change: 1 addition & 0 deletions includes/class-installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ private function create_general_options() {
'cpseo_wc_remove_generator' => 'on',
'cpseo_remove_shop_snippet_data' => 'on',
'cpseo_usage_tracking' => 'on',
'cpseo_remove_data_on_uninstall' => 'off',
]));
}

Expand Down
89 changes: 0 additions & 89 deletions includes/class-updates.php

This file was deleted.

2 changes: 1 addition & 1 deletion includes/helpers/class-wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ private static function get_role_capabilities( $slug, $caps, &$data ) {
*/
public static function set_capabilities( $roles ) {
$caps = array_keys( self::get_capabilities() );
foreach ( WP_Helper::get_roles() as $slug => $role ) {
foreach ( self::get_roles() as $slug => $role ) {
self::set_role_capabilities( $slug, $caps, $roles );
}
}
Expand Down
4 changes: 3 additions & 1 deletion includes/modules/404-monitor/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#[\AllowDynamicProperties]
class Admin extends Base {

use WordPress;

/**
* The Constructor.
*
Expand Down Expand Up @@ -66,7 +68,7 @@ public function __construct() {
* @codeCoverageIgnore
*/
public function init() {
$action = WordPress::get_request_action();
$action = self::get_request_action();
if ( false === $action || ! in_array( $action, [ 'delete', 'clear_log' ], true ) ) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion includes/modules/redirections/class-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function get_views() {
$url . '&status=' . $key,
$key === $current ? ' class="current"' : '',
$label,
number_format_i18n( $counts[ $key ] )
number_format_i18n( $counts[ $key ] ?? 0 )
);
}

Expand Down
8 changes: 5 additions & 3 deletions includes/modules/rich-snippet/snippets/class-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#[\AllowDynamicProperties]
class Event implements Snippet {

use Helper;

/**
* Event rich snippet.
*
Expand Down Expand Up @@ -47,10 +49,10 @@ public function process( $data, $jsonld ) {
];

if ( $start_date = Helper::get_post_meta( 'snippet_event_startdate' ) ) { // phpcs:ignore
$entity['startDate'] = str_replace( ' ', 'T', Helper::convert_date( $start_date ) );
$entity['startDate'] = str_replace( ' ', 'T', self::convert_date( $start_date ) );
}
if ( $end_date = Helper::get_post_meta( 'snippet_event_enddate' ) ) { // phpcs:ignore
$entity['endDate'] = str_replace( ' ', 'T', Helper::convert_date( $end_date ) );
$entity['endDate'] = str_replace( ' ', 'T', self::convert_date( $end_date ) );
}

$jsonld->add_ratings( 'event', $entity );
Expand All @@ -65,7 +67,7 @@ public function process( $data, $jsonld ) {
], $entity['offers'] );

if ( ! empty( $entity['offers']['validFrom'] ) ) {
$entity['offers']['validFrom'] = str_replace( ' ', 'T', Helper::convert_date( $entity['offers']['validFrom'] ) );
$entity['offers']['validFrom'] = str_replace( ' ', 'T', self::convert_date( $entity['offers']['validFrom'] ) );
}

if ( empty( $entity['offers']['price'] ) ) {
Expand Down
8 changes: 8 additions & 0 deletions includes/settings/general/others.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
'default' => 'on',
]);

$cmb->add_field([
'id' => 'cpseo_remove_data_on_uninstall',
'type' => 'switch',
'name' => esc_html__( 'Remove all data on uninstall', 'cpseo' ),
'desc' => esc_html__( 'Clean all options and delete database tables on uninstall.', 'cpseo' ),
'default' => 'off',
]);

$cmb->add_field([
'id' => 'cpseo_rss_before_content',
'type' => 'textarea_small',
Expand Down
Loading

0 comments on commit 050cc17

Please sign in to comment.