Commit inicial - WordPress Análisis de Precios Unitarios

- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

View File

@@ -0,0 +1,322 @@
<?php
/** Used to view Pending comments, Spam Comments, Trash comments, Pingbacks and Trackbacks */
class ADBC_Clean_Comment extends WP_List_Table {
private $aDBc_message = "";
private $aDBc_class_message = "updated";
private $aDBc_elements_to_display = array();
private $aDBc_type_to_clean = "";
private $aDBc_plural_title = "";
private $aDBc_column_comment_name = "";
private $aDBc_sql_get_elements = "";
private $aDBc_custom_sql_args = "";
private $aDBc_search_sql_arg = "";
private $aDBc_order_by_sql_arg = "";
private $aDBc_limit_offset_sql_arg = "";
private $aDBc_keep_last_sql_arg = "";
/**
* Constructor
*/
function __construct($element_type){
if($element_type == "moderated-comments"){
$this->aDBc_type_to_clean = "0";
$aDBc_singular = __('Pending comment', 'advanced-database-cleaner');
$this->aDBc_plural_title = __('Pending comments', 'advanced-database-cleaner');
$this->aDBc_column_comment_name = __('Comment content', 'advanced-database-cleaner');
$this->aDBc_custom_sql_args = " comment_approved = '0'";
$this->aDBc_keep_last_sql_arg = $this->aDBc_get_keep_last_sql_arg('moderated-comments');
}else if($element_type == "spam-comments"){
$this->aDBc_type_to_clean = "spam";
$aDBc_singular = __('Spam comment', 'advanced-database-cleaner');
$this->aDBc_plural_title = __('Spam comments', 'advanced-database-cleaner');
$this->aDBc_column_comment_name = __('Comment content', 'advanced-database-cleaner');
$this->aDBc_custom_sql_args = " comment_approved = 'spam'";
$this->aDBc_keep_last_sql_arg = $this->aDBc_get_keep_last_sql_arg('spam-comments');
}else if($element_type == "trash-comments"){
$this->aDBc_type_to_clean = "trash";
$aDBc_singular = __('Trash comment', 'advanced-database-cleaner');
$this->aDBc_plural_title = __('Trash comments', 'advanced-database-cleaner');
$this->aDBc_column_comment_name = __('Comment content', 'advanced-database-cleaner');
$this->aDBc_custom_sql_args = " comment_approved = 'trash'";
$this->aDBc_keep_last_sql_arg = $this->aDBc_get_keep_last_sql_arg('trash-comments');
}else if($element_type == "pingbacks"){
$this->aDBc_type_to_clean = "pingback";
$aDBc_singular = __('Pingback', 'advanced-database-cleaner');
$this->aDBc_plural_title = __('Pingbacks', 'advanced-database-cleaner');
$this->aDBc_column_comment_name = __('Pingback content', 'advanced-database-cleaner');
$this->aDBc_custom_sql_args = " comment_type = 'pingback'";
$this->aDBc_keep_last_sql_arg = $this->aDBc_get_keep_last_sql_arg('pingbacks');
}else if($element_type == "trackbacks"){
$this->aDBc_type_to_clean = "trackback";
$aDBc_singular = __('Trackback', 'advanced-database-cleaner');
$this->aDBc_plural_title = __('Trackbacks', 'advanced-database-cleaner');
$this->aDBc_column_comment_name = __('Trackback content', 'advanced-database-cleaner');
$this->aDBc_custom_sql_args = " comment_type = 'trackback'";
$this->aDBc_keep_last_sql_arg = $this->aDBc_get_keep_last_sql_arg('trackbacks');
}
// Prepare additional sql args if any: per page, LIMIT, OFFSET, etc.
if ( ADBC_PLUGIN_PLAN == "pro" ) {
$this->aDBc_search_sql_arg = aDBc_get_search_sql_arg( "comment_author", "comment_content" );
}
$this->aDBc_order_by_sql_arg = aDBc_get_order_by_sql_arg( "comment_ID" );
$this->aDBc_limit_offset_sql_arg = aDBc_get_limit_offset_sql_args();
parent::__construct(array(
'singular' => $aDBc_singular,
'plural' => $this->aDBc_plural_title,
'ajax' => false
));
$this->aDBc_prepare_elements_to_clean();
$this->aDBc_print_page_content();
}
/** Prepare elements to display */
function aDBc_prepare_elements_to_clean(){
global $wpdb;
// Process bulk action if any before preparing elements to clean
$this->process_bulk_action();
// Get all elements to clean
if(function_exists('is_multisite') && is_multisite()){
$blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
foreach($blogs_ids as $blog_id){
switch_to_blog($blog_id);
$this->aDBc_fill_array_elements_to_clean($blog_id);
restore_current_blog();
}
}else{
$this->aDBc_fill_array_elements_to_clean("1");
}
// Call WP prepare_items function
$this->prepare_items();
}
/** Fill array elements to display */
function aDBc_fill_array_elements_to_clean($blog_id){
global $wpdb;
// Get all elements query
$this->aDBc_sql_get_elements = "SELECT comment_ID, comment_author, comment_content, comment_date FROM $wpdb->comments WHERE"
. $this->aDBc_custom_sql_args
. $this->aDBc_keep_last_sql_arg
. $this->aDBc_search_sql_arg
. $this->aDBc_order_by_sql_arg
//. $this->aDBc_limit_offset_sql_arg
;
$aDBc_all_elements = $wpdb->get_results($this->aDBc_sql_get_elements);
foreach($aDBc_all_elements as $aDBc_element){
// Get author name
$author_name = aDBc_create_tooltip_for_long_string($aDBc_element->comment_author, 16);
// Get comment content
$comment_content = aDBc_create_tooltip_for_long_string($aDBc_element->comment_content, 60);
array_push($this->aDBc_elements_to_display, array(
'comment_id' => $aDBc_element->comment_ID,
'comment_author' => $author_name,
'comment_content' => $comment_content,
'comment_date' => $aDBc_element->comment_date,
'site_id' => $blog_id
)
);
}
}
/** Prepare keep_last element if any **/
function aDBc_get_keep_last_sql_arg($element_type){
$settings = get_option('aDBc_settings');
if(!empty($settings['keep_last'])){
$keep_setting = $settings['keep_last'];
if(!empty($keep_setting[$element_type]))
return " and comment_date < NOW() - INTERVAL " . $keep_setting[$element_type] . " DAY";
}
return "";
}
/** WP: Get columns */
function get_columns(){
$columns = array(
'cb' => '<input type="checkbox" />',
'comment_id' => __('ID','advanced-database-cleaner'),
'comment_author' => __('Author','advanced-database-cleaner'),
'comment_content' => $this->aDBc_column_comment_name,
'comment_date' => __('Date','advanced-database-cleaner'),
'site_id' => __('Site id','advanced-database-cleaner')
);
return $columns;
}
/** WP: Column default */
function column_default($item, $column_name){
switch($column_name){
case 'comment_id':
case 'comment_author':
case 'comment_content':
case 'comment_date':
case 'site_id':
return $item[$column_name];
default:
return print_r($item, true) ; //Show the whole array for troubleshooting purposes
}
}
/** WP: Get columns that should be hidden */
function get_hidden_columns(){
// If MU, nothing to hide, else hide Side ID column
if(function_exists('is_multisite') && is_multisite()){
return array();
}else{
return array('site_id');
}
}
function get_sortable_columns() {
$sortable_columns = array(
'comment_id' => array('comment_ID',false),
'comment_author' => array('comment_author',false)
);
// Since order_by works directly with sql request, we will not order_by in mutlisite since it will not work
if(function_exists('is_multisite') && is_multisite()){
return array();
}else{
return $sortable_columns;
}
}
/** WP: Prepare items to display */
function prepare_items() {
$columns = $this->get_columns();
$hidden = $this->get_hidden_columns();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$per_page = 50;
if(!empty($_GET['per_page'])){
$per_page = absint($_GET['per_page']);
}
$current_page = $this->get_pagenum();
// Prepare sequence of elements to display
$display_data = array_slice($this->aDBc_elements_to_display,(($current_page-1) * $per_page), $per_page);
$this->set_pagination_args( array(
'total_items' => count($this->aDBc_elements_to_display),
'per_page' => $per_page
));
$this->items = $display_data;
}
/** WP: Column cb for check box */
function column_cb($item) {
return sprintf('<input type="checkbox" name="aDBc_elements_to_process[]" value="%s" />', $item['site_id']."|".$item['comment_id']);
}
/** WP: Get bulk actions */
function get_bulk_actions() {
$actions = array(
'clean' => __('Clean','advanced-database-cleaner')
);
return $actions;
}
/** WP: Message to display when no items found */
function no_items() {
_e('No elements found!','advanced-database-cleaner');
}
/** WP: Process bulk actions */
public function process_bulk_action() {
// Detect when a bulk action is being triggered.
$action = $this->current_action();
if ( ! $action )
return;
// security check!
check_admin_referer( 'bulk-' . $this->_args['plural'] );
// Check role
if ( ! current_user_can( 'administrator' ) )
wp_die( 'Security check failed!' );
if ( $action == 'clean' ) {
// If the user wants to clean the elements he/she selected
if(isset($_POST['aDBc_elements_to_process'])){
if(function_exists('is_multisite') && is_multisite()){
// Prepare elements to delete
$elements_to_delete = array();
foreach($_POST['aDBc_elements_to_process'] as $element){
$element_info = explode("|", $element);
$sanitized_site_id = sanitize_html_class($element_info[0]);
$sanitized_item_id = sanitize_html_class($element_info[1]);
// For security, we only proceed if both parts are clean and are numbers
if(is_numeric($sanitized_site_id) && is_numeric($sanitized_item_id)){
if(empty($elements_to_delete[$sanitized_site_id])){
$elements_to_delete[$sanitized_site_id] = array();
}
array_push($elements_to_delete[$sanitized_site_id], $sanitized_item_id);
}
}
// Delete elements
foreach($elements_to_delete as $site_id => $elements_ids){
switch_to_blog($site_id);
global $wpdb;
foreach($elements_ids as $id_comment) {
$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID = $id_comment");
}
restore_current_blog();
}
}else{
global $wpdb;
foreach($_POST['aDBc_elements_to_process'] as $element) {
$element_info = explode("|", $element);
$sanitized_id = sanitize_html_class($element_info[1]);
if(is_numeric($sanitized_id)){
$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID = " . $sanitized_id);
}
}
}
// Update the message to show to the user
$this->aDBc_message = __("Selected '$this->aDBc_plural_title' successfully cleaned!", 'advanced-database-cleaner');
}
}
}
/** Print the page content */
function aDBc_print_page_content(){
include_once 'page_custom_clean.php';
}
}
?>

View File

@@ -0,0 +1,311 @@
<?php
/** View comment meta and post meta */
class ADBC_Clean_Meta_Comment_Post_User_Term extends WP_List_Table {
private $aDBc_message = "";
private $aDBc_class_message = "updated";
private $aDBc_elements_to_display = array();
private $aDBc_type_to_clean = "";
private $aDBc_plural_title = "";
private $aDBc_column_meta_name = "";
private $aDBc_sql_get_elements = "";
private $aDBc_custom_sql_args = "";
private $aDBc_search_sql_arg = "";
private $aDBc_order_by_sql_arg = "";
private $aDBc_limit_offset_sql_arg = "";
private $aDBc_delete_from_table = "";
private $aDBc_metaid_or_umetaid = "";
/**
* Constructor
*/
function __construct($element_type){
if($element_type == "orphan-commentmeta"){
$this->aDBc_type_to_clean = "orphan-commentmeta";
$aDBc_singular = __('Orphaned comment meta', 'advanced-database-cleaner');
$this->aDBc_plural_title = __('Orphaned comments meta', 'advanced-database-cleaner');
$this->aDBc_column_meta_name = __('Comment meta key', 'advanced-database-cleaner');
$this->aDBc_delete_from_table = "commentmeta";
$this->aDBc_metaid_or_umetaid = "meta_id";
}else if($element_type == "orphan-postmeta"){
$this->aDBc_type_to_clean = "orphan-postmeta";
$aDBc_singular = __('Orphaned post meta', 'advanced-database-cleaner');
$this->aDBc_plural_title = __('Orphaned posts meta', 'advanced-database-cleaner');
$this->aDBc_column_meta_name = __('Post meta key', 'advanced-database-cleaner');
$this->aDBc_delete_from_table = "postmeta";
$this->aDBc_metaid_or_umetaid = "meta_id";
}else if($element_type == "orphan-usermeta"){
$this->aDBc_type_to_clean = "orphan-usermeta";
$aDBc_singular = __('Orphaned User Meta', 'advanced-database-cleaner');
$this->aDBc_plural_title = __('Orphaned Users Meta', 'advanced-database-cleaner');
$this->aDBc_column_meta_name = __('User meta key', 'advanced-database-cleaner');
$this->aDBc_delete_from_table = "usermeta";
$this->aDBc_metaid_or_umetaid = "umeta_id";
}else if($element_type == "orphan-termmeta"){
$this->aDBc_type_to_clean = "orphan-termmeta";
$aDBc_singular = __('Orphaned Term Meta', 'advanced-database-cleaner');
$this->aDBc_plural_title = __('Orphaned Terms Meta', 'advanced-database-cleaner');
$this->aDBc_column_meta_name = __('Term meta key', 'advanced-database-cleaner');
$this->aDBc_delete_from_table = "termmeta";
$this->aDBc_metaid_or_umetaid = "meta_id";
}
// Prepare additional sql args if any: per page, LIMIT, OFFSET, etc.
if ( ADBC_PLUGIN_PLAN == "pro" ) {
$this->aDBc_search_sql_arg = aDBc_get_search_sql_arg( "meta_key", "meta_value" );
}
$this->aDBc_order_by_sql_arg = aDBc_get_order_by_sql_arg( $this->aDBc_metaid_or_umetaid );
$this->aDBc_limit_offset_sql_arg = aDBc_get_limit_offset_sql_args();
parent::__construct(array(
'singular' => $aDBc_singular,
'plural' => $this->aDBc_plural_title,
'ajax' => false
));
$this->aDBc_prepare_elements_to_clean();
$this->aDBc_print_page_content();
}
/** Prepare elements to display */
function aDBc_prepare_elements_to_clean(){
global $wpdb;
// Process bulk action if any before preparing elements to clean
$this->process_bulk_action();
// Get all elements (for the table usermeta, only one table exists for MU, do not switch over blogs for it)
if(function_exists('is_multisite') && is_multisite() && $this->aDBc_type_to_clean != "orphan-usermeta"){
$blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
foreach($blogs_ids as $blog_id){
switch_to_blog($blog_id);
$this->aDBc_fill_array_elements_to_clean($blog_id);
restore_current_blog();
}
}else{
$this->aDBc_fill_array_elements_to_clean("1");
}
// Call WP prepare_items function
$this->prepare_items();
}
/** Fill array elements to display */
function aDBc_fill_array_elements_to_clean($blog_id){
global $wpdb;
if($this->aDBc_type_to_clean == "orphan-commentmeta"){
$this->aDBc_custom_sql_args = "SELECT meta_id, meta_key, meta_value FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM $wpdb->comments)";
}else if($this->aDBc_type_to_clean == "orphan-postmeta"){
$this->aDBc_custom_sql_args = "SELECT meta_id, meta_key, meta_value FROM $wpdb->postmeta pm LEFT JOIN $wpdb->posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL";
}else if($this->aDBc_type_to_clean == "orphan-usermeta"){
$this->aDBc_custom_sql_args = "SELECT umeta_id, meta_key, meta_value FROM $wpdb->usermeta WHERE user_id NOT IN (SELECT ID FROM $wpdb->users)";
}else if($this->aDBc_type_to_clean == "orphan-termmeta"){
$this->aDBc_custom_sql_args = "SELECT meta_id, meta_key, meta_value FROM $wpdb->termmeta WHERE term_id NOT IN (SELECT term_id FROM $wpdb->terms)";
}
// Get all elements query
$this->aDBc_sql_get_elements = $this->aDBc_custom_sql_args
. $this->aDBc_search_sql_arg
. $this->aDBc_order_by_sql_arg
//. $this->aDBc_limit_offset_sql_arg
;
$aDBc_all_elements = $wpdb->get_results($this->aDBc_sql_get_elements);
foreach($aDBc_all_elements as $aDBc_element){
// Get meta key
$meta_key = aDBc_create_tooltip_for_long_string($aDBc_element->meta_key, 28);
// Get meta value
$meta_value = aDBc_create_tooltip_for_long_string($aDBc_element->meta_value, 95);
array_push($this->aDBc_elements_to_display, array(
'meta_id' => ($this->aDBc_metaid_or_umetaid == 'meta_id' ? $aDBc_element->meta_id : $aDBc_element->umeta_id),
'meta_key' => $meta_key,
'meta_value' => $meta_value,
'site_id' => $blog_id
)
);
}
}
/** WP: Get columns */
function get_columns(){
$columns = array(
'cb' => '<input type="checkbox" />',
'meta_id' => __('ID','advanced-database-cleaner'),
'meta_key' => $this->aDBc_column_meta_name,
'meta_value' => __('Meta value','advanced-database-cleaner'),
'site_id' => __('Site id','advanced-database-cleaner')
);
return $columns;
}
/** WP: Column default */
function column_default($item, $column_name){
switch($column_name){
case 'meta_id':
case 'meta_key':
case 'meta_value':
case 'site_id':
return $item[$column_name];
default:
return print_r($item, true) ; //Show the whole array for troubleshooting purposes
}
}
/** WP: Get columns that should be hidden */
function get_hidden_columns(){
// If MU, nothing to hide, else hide Side ID column
if(function_exists('is_multisite') && is_multisite()){
return array();
}else{
return array('site_id');
}
}
function get_sortable_columns() {
$sortable_columns = array(
'meta_id' => array($this->aDBc_metaid_or_umetaid, false),
'meta_key' => array('meta_key', false)
);
// Since order_by works directly with sql request, we will not order_by in mutlisite since it will not work
if(function_exists('is_multisite') && is_multisite()){
return array();
}else{
return $sortable_columns;
}
}
/** WP: Prepare items to display */
function prepare_items() {
$columns = $this->get_columns();
$hidden = $this->get_hidden_columns();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$per_page = 50;
if(!empty($_GET['per_page'])){
$per_page = absint($_GET['per_page']);
}
$current_page = $this->get_pagenum();
// Prepare sequence of elements to display
$display_data = array_slice($this->aDBc_elements_to_display,(($current_page-1) * $per_page), $per_page);
$this->set_pagination_args( array(
'total_items' => count($this->aDBc_elements_to_display),
'per_page' => $per_page
));
$this->items = $display_data;
}
/** WP: Column cb for check box */
function column_cb($item) {
return sprintf('<input type="checkbox" name="aDBc_elements_to_process[]" value="%s" />', $item['site_id']."|".$item['meta_id']);
}
/** WP: Get bulk actions */
function get_bulk_actions() {
$actions = array(
'clean' => __('Clean','advanced-database-cleaner')
);
return $actions;
}
/** WP: Message to display when no items found */
function no_items() {
_e('No elements found!','advanced-database-cleaner');
}
/** WP: Process bulk actions */
public function process_bulk_action() {
// Detect when a bulk action is being triggered.
$action = $this->current_action();
if ( ! $action )
return;
// security check!
check_admin_referer( 'bulk-' . $this->_args['plural'] );
// Check role
if ( ! current_user_can( 'administrator' ) )
wp_die( 'Security check failed!' );
if ( $action == 'clean' ) {
// If the user wants to clean the elements he/she selected
if(isset($_POST['aDBc_elements_to_process'])){
if(function_exists('is_multisite') && is_multisite()){
// Prepare meta to delete
$meta_to_delete = array();
foreach($_POST['aDBc_elements_to_process'] as $meta){
$meta_info = explode("|", $meta);
$sanitized_site_id = sanitize_html_class($meta_info[0]);
$sanitized_item_id = sanitize_html_class($meta_info[1]);
// For security, we only proceed if both parts are clean and are numbers
if(is_numeric($sanitized_site_id) && is_numeric($sanitized_item_id)){
if(empty($meta_to_delete[$sanitized_site_id])){
$meta_to_delete[$sanitized_site_id] = array();
}
array_push($meta_to_delete[$sanitized_site_id], $sanitized_item_id);
}
}
// Delete meta
foreach($meta_to_delete as $site_id => $meta_ids){
switch_to_blog($site_id);
global $wpdb;
foreach($meta_ids as $id_meta) {
$table_name = $wpdb->prefix . $this->aDBc_delete_from_table;
$wpdb->query("DELETE FROM $table_name WHERE $this->aDBc_metaid_or_umetaid = $id_meta");
}
restore_current_blog();
}
}else{
global $wpdb;
$table_name = $wpdb->prefix . $this->aDBc_delete_from_table;
foreach($_POST['aDBc_elements_to_process'] as $meta) {
$meta_info = explode("|", $meta);
$sanitized_id = sanitize_html_class($meta_info[1]);
if(is_numeric($sanitized_id)){
$wpdb->query("DELETE FROM $table_name WHERE $this->aDBc_metaid_or_umetaid = " . $sanitized_id);
}
}
}
// Update the message to show to the user
$this->aDBc_message = __("Selected '$this->aDBc_plural_title' successfully cleaned!", "advanced-database-cleaner");
}
}
}
/** Print the page content */
function aDBc_print_page_content(){
include_once 'page_custom_clean.php';
}
}
?>

View File

@@ -0,0 +1,257 @@
<?php
class ADBC_Clean_Relationship extends WP_List_Table {
private $aDBc_message = "";
private $aDBc_class_message = "updated";
private $aDBc_elements_to_display = array();
private $aDBc_type_to_clean = "";
private $aDBc_plural_title = "";
private $aDBc_column_meta_name = "";
private $aDBc_sql_get_elements = "";
private $aDBc_search_sql_arg = "";
private $aDBc_order_by_sql_arg = "";
private $aDBc_limit_offset_sql_arg = "";
private $aDBc_delete_from_table = "";
/**
* Constructor
*/
function __construct(){
$this->aDBc_plural_title = __('Orphaned Relationships', 'advanced-database-cleaner');
// Prepare additional sql args if any: per page, LIMIT, OFFSET, etc.
if ( ADBC_PLUGIN_PLAN == "pro" ) {
$this->aDBc_search_sql_arg = aDBc_get_search_sql_arg( "term_taxonomy_id", "term_order" );
}
$this->aDBc_order_by_sql_arg = aDBc_get_order_by_sql_arg( "object_id" );
$this->aDBc_limit_offset_sql_arg = aDBc_get_limit_offset_sql_args();
parent::__construct(array(
'singular' => __( 'Orphaned Relationship', 'advanced-database-cleaner' ),
'plural' => $this->aDBc_plural_title,
'ajax' => false
));
$this->aDBc_prepare_elements_to_clean();
$this->aDBc_print_page_content();
}
/** Prepare elements to display */
function aDBc_prepare_elements_to_clean(){
global $wpdb;
// Process bulk action if any before preparing elements to clean
$this->process_bulk_action();
// Get all elements to clean
if(function_exists('is_multisite') && is_multisite()){
$blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
foreach($blogs_ids as $blog_id){
switch_to_blog($blog_id);
$this->aDBc_fill_array_elements_to_clean($blog_id);
restore_current_blog();
}
}else{
$this->aDBc_fill_array_elements_to_clean("1");
}
// Call WP prepare_items function
$this->prepare_items();
}
/** Fill array elements to display */
function aDBc_fill_array_elements_to_clean($blog_id){
global $wpdb;
// Get all elements query
$this->aDBc_sql_get_elements = "SELECT * from $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM $wpdb->posts)"
. $this->aDBc_search_sql_arg
. $this->aDBc_order_by_sql_arg
//. $this->aDBc_limit_offset_sql_arg
;
$aDBc_all_elements = $wpdb->get_results($this->aDBc_sql_get_elements);
foreach($aDBc_all_elements as $aDBc_element){
array_push($this->aDBc_elements_to_display, array(
'object_id' => $aDBc_element->object_id,
'term_taxonomy_id' => $aDBc_element->term_taxonomy_id,
'term_order' => $aDBc_element->term_order,
'site_id' => $blog_id
)
);
}
}
/** WP: Get columns */
function get_columns(){
$columns = array(
'cb' => '<input type="checkbox" />',
'object_id' => __('ID','advanced-database-cleaner'),
'term_taxonomy_id' => __('Term taxonomy id','advanced-database-cleaner'),
'term_order' => __('Term order','advanced-database-cleaner'),
'site_id' => __('Site id','advanced-database-cleaner')
);
return $columns;
}
/** WP: Column default */
function column_default($item, $column_name){
switch($column_name){
case 'object_id':
case 'term_taxonomy_id':
case 'term_order':
case 'site_id':
return $item[$column_name];
default:
return print_r($item, true) ; //Show the whole array for troubleshooting purposes
}
}
/** WP: Get columns that should be hidden */
function get_hidden_columns(){
// If MU, nothing to hide, else hide Side ID column
if(function_exists('is_multisite') && is_multisite()){
return array();
}else{
return array('site_id');
}
}
function get_sortable_columns() {
$sortable_columns = array(
'object_id' => array('object_id',false),
'term_taxonomy_id' => array('term_taxonomy_id',false),
'term_order' => array('term_order',false)
);
// Since order_by works directly with sql request, we will not order_by in mutlisite since it will not work
if(function_exists('is_multisite') && is_multisite()){
return array();
}else{
return $sortable_columns;
}
}
/** WP: Prepare items to display */
function prepare_items() {
$columns = $this->get_columns();
$hidden = $this->get_hidden_columns();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$per_page = 50;
if(!empty($_GET['per_page'])){
$per_page = absint($_GET['per_page']);
}
$current_page = $this->get_pagenum();
// Prepare sequence of elements to display
$display_data = array_slice($this->aDBc_elements_to_display,(($current_page-1) * $per_page), $per_page);
$this->set_pagination_args( array(
'total_items' => count($this->aDBc_elements_to_display),
'per_page' => $per_page
));
$this->items = $display_data;
}
/** WP: Column cb for check box */
function column_cb($item) {
return sprintf('<input type="checkbox" name="aDBc_elements_to_process[]" value="%s" />', $item['site_id']."|".$item['object_id']);
}
/** WP: Get bulk actions */
function get_bulk_actions() {
$actions = array(
'clean' => __('Clean','advanced-database-cleaner')
);
return $actions;
}
/** WP: Message to display when no items found */
function no_items() {
_e('No elements found!','advanced-database-cleaner');
}
/** WP: Process bulk actions */
public function process_bulk_action() {
// Detect when a bulk action is being triggered.
$action = $this->current_action();
if ( ! $action )
return;
// security check!
check_admin_referer( 'bulk-' . $this->_args['plural'] );
// Check role
if ( ! current_user_can( 'administrator' ) )
wp_die( 'Security check failed!' );
if ( $action == 'clean' ) {
// If the user wants to clean the elements he/she selected
if(isset($_POST['aDBc_elements_to_process'])){
if(function_exists('is_multisite') && is_multisite()){
// Prepare relationships to delete
$relationships_to_delete = array();
foreach($_POST['aDBc_elements_to_process'] as $relationship){
$relationship_info = explode("|", $relationship);
$sanitized_site_id = sanitize_html_class($relationship_info[0]);
$sanitized_item_id = sanitize_html_class($relationship_info[1]);
// For security, we only proceed if both parts are clean and are numbers
if(is_numeric($sanitized_site_id) && is_numeric($sanitized_item_id)){
if(empty($relationships_to_delete[$sanitized_site_id])){
$relationships_to_delete[$sanitized_site_id] = array();
}
array_push($relationships_to_delete[$sanitized_site_id], $sanitized_item_id);
}
}
// Delete relationships
foreach($relationships_to_delete as $site_id => $object_ids){
switch_to_blog($site_id);
global $wpdb;
foreach($object_ids as $object_id) {
$wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id = $object_id");
}
restore_current_blog();
}
}else{
global $wpdb;
foreach($_POST['aDBc_elements_to_process'] as $relationship){
$relationship_info = explode("|", $relationship);
$sanitized_id = sanitize_html_class($relationship_info[1]);
if(is_numeric($sanitized_id)){
$wpdb->query("DELETE FROM $wpdb->term_relationships WHERE term_taxonomy_id=1 AND object_id = " . $sanitized_id);
}
}
}
// Update the message to show to the user
$this->aDBc_message = __("Selected 'Orphaned relationships' successfully cleaned!", "advanced-database-cleaner");
}
}
}
/** Print the page content */
function aDBc_print_page_content(){
include_once 'page_custom_clean.php';
}
}
?>

View File

@@ -0,0 +1,303 @@
<?php
/** Used to view revisions, auto-drafts and trash posts */
class ADBC_Clean_Revision_Trash_Draft extends WP_List_Table {
private $aDBc_message = "";
private $aDBc_class_message = "updated";
private $aDBc_elements_to_display = array();
private $aDBc_type_to_clean = "";
private $aDBc_plural_title = "";
private $aDBc_column_post_name_title = "";
private $aDBc_sql_get_elements = "";
private $aDBc_custom_sql_args = "";
private $aDBc_search_sql_arg = "";
private $aDBc_order_by_sql_arg = "";
private $aDBc_limit_offset_sql_arg = "";
private $aDBc_keep_last_sql_arg = "";
/**
* Constructor
*/
function __construct($element_type){
if($element_type == "auto-draft"){
$this->aDBc_type_to_clean = "auto-draft";
$aDBc_singular = __('Auto draft', 'advanced-database-cleaner');
$this->aDBc_plural_title = __('Auto drafts', 'advanced-database-cleaner');
$this->aDBc_column_post_name_title = __('Auto draft title', 'advanced-database-cleaner');
$this->aDBc_custom_sql_args = " post_status = 'auto-draft'";
$this->aDBc_keep_last_sql_arg = $this->aDBc_get_keep_last_sql_arg('auto-draft');
}else if($element_type == "trash-posts"){
$this->aDBc_type_to_clean = "trash";
$aDBc_singular = __('Trash post', 'advanced-database-cleaner');
$this->aDBc_plural_title = __('Trash posts', 'advanced-database-cleaner');
$this->aDBc_column_post_name_title = __('Trash post title', 'advanced-database-cleaner');
$this->aDBc_custom_sql_args = " post_status = 'trash'";
$this->aDBc_keep_last_sql_arg = $this->aDBc_get_keep_last_sql_arg('trash-posts');
}else if($element_type == "revision"){
$this->aDBc_type_to_clean = "revision";
$aDBc_singular = __('Revision', 'advanced-database-cleaner');
$this->aDBc_plural_title = __('Revisions', 'advanced-database-cleaner');
$this->aDBc_column_post_name_title = __('Revision title', 'advanced-database-cleaner');
$this->aDBc_custom_sql_args = " post_type = 'revision'";
$this->aDBc_keep_last_sql_arg = $this->aDBc_get_keep_last_sql_arg('revision');
}
// Prepare additional sql args if any: per page, LIMIT, OFFSET, etc.
if ( ADBC_PLUGIN_PLAN == "pro" ) {
$this->aDBc_search_sql_arg = aDBc_get_search_sql_arg( "post_title", "post_content" );
}
$this->aDBc_order_by_sql_arg = aDBc_get_order_by_sql_arg( "ID" );
$this->aDBc_limit_offset_sql_arg = aDBc_get_limit_offset_sql_args();
parent::__construct(array(
'singular' => $aDBc_singular,
'plural' => $this->aDBc_plural_title,
'ajax' => false
));
$this->aDBc_prepare_elements_to_clean();
$this->aDBc_print_page_content();
}
/** Prepare elements to display */
function aDBc_prepare_elements_to_clean(){
global $wpdb;
// Process bulk action if any before preparing elements to clean
$this->process_bulk_action();
// Get all elements to clean
if(function_exists('is_multisite') && is_multisite()){
$blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
foreach($blogs_ids as $blog_id){
switch_to_blog($blog_id);
$this->aDBc_fill_array_elements_to_clean($blog_id);
restore_current_blog();
}
}else{
$this->aDBc_fill_array_elements_to_clean("1");
}
// Call WP prepare_items function
$this->prepare_items();
}
/** Fill array elements to display */
function aDBc_fill_array_elements_to_clean($blog_id){
global $wpdb;
// Get all elements query
$this->aDBc_sql_get_elements = "SELECT ID, post_title, post_date, post_content FROM $wpdb->posts WHERE"
. $this->aDBc_custom_sql_args
. $this->aDBc_keep_last_sql_arg
. $this->aDBc_search_sql_arg
. $this->aDBc_order_by_sql_arg
//. $this->aDBc_limit_offset_sql_arg
;
$aDBc_all_elements = $wpdb->get_results($this->aDBc_sql_get_elements);
foreach($aDBc_all_elements as $aDBc_element){
// Susbstr post title
$post_title = aDBc_create_tooltip_for_long_string($aDBc_element->post_title, 35);
// Get content
$post_content = aDBc_create_tooltip_for_long_string($aDBc_element->post_content, 35);
array_push($this->aDBc_elements_to_display, array(
'post_id' => $aDBc_element->ID,
'post_title' => $post_title,
'post_content' => $post_content, //xxx add if empty, replace by 'Empty' to prevent responsive issues in WP table
'post_date' => $aDBc_element->post_date,
'site_id' => $blog_id
)
);
}
}
/** Prepare keep_last element if any **/
function aDBc_get_keep_last_sql_arg($element_type){
$settings = get_option('aDBc_settings');
if(!empty($settings['keep_last'])){
$keep_setting = $settings['keep_last'];
if(!empty($keep_setting[$element_type]))
return " and post_modified < NOW() - INTERVAL " . $keep_setting[$element_type] . " DAY";
}
return "";
}
/** WP: Get columns */
function get_columns(){
$columns = array(
'cb' => '<input type="checkbox" />',
'post_id' => __('ID','advanced-database-cleaner'),
'post_title' => $this->aDBc_column_post_name_title,
'post_content' => __('Content','advanced-database-cleaner'),
'post_date' => __('Date','advanced-database-cleaner'),
'site_id' => __('Site id','advanced-database-cleaner')
);
return $columns;
}
/** WP: Column default */
function column_default($item, $column_name){
switch($column_name){
case 'post_id':
case 'post_title':
case 'post_content':
case 'post_date':
case 'site_id':
return $item[$column_name];
default:
return print_r($item, true) ; //Show the whole array for troubleshooting purposes
}
}
/** WP: Get columns that should be hidden */
function get_hidden_columns(){
// If MU, nothing to hide, else hide Side ID column
if(function_exists('is_multisite') && is_multisite()){
return array();
}else{
return array('site_id');
}
}
function get_sortable_columns() {
$sortable_columns = array(
'post_id' => array('ID',false), //true means it's already sorted
'post_title' => array('post_title',false),
'post_date' => array('post_date',false)
);
// Since order_by works directly with sql request, we will not order_by in mutlisite since it will not work
if(function_exists('is_multisite') && is_multisite()){
return array();
}else{
return $sortable_columns;
}
}
/** WP: Prepare items to display */
function prepare_items() {
$columns = $this->get_columns();
$hidden = $this->get_hidden_columns();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$per_page = 50;
if(!empty($_GET['per_page'])){
$per_page = absint($_GET['per_page']);
}
$current_page = $this->get_pagenum();
// Prepare sequence of elements to display
$display_data = array_slice($this->aDBc_elements_to_display,(($current_page-1) * $per_page), $per_page);
$this->set_pagination_args( array(
'total_items' => count($this->aDBc_elements_to_display),
'per_page' => $per_page
));
$this->items = $display_data;
}
/** WP: Column cb for check box */
function column_cb($item) {
return sprintf('<input type="checkbox" name="aDBc_elements_to_process[]" value="%s" />', $item['site_id']."|".$item['post_id']);
}
/** WP: Get bulk actions */
function get_bulk_actions() {
$actions = array(
'clean' => __('Clean','advanced-database-cleaner')
);
return $actions;
}
/** WP: Message to display when no items found */
function no_items() {
_e('No elements found!','advanced-database-cleaner');
}
/** WP: Process bulk actions */
public function process_bulk_action() {
// Detect when a bulk action is being triggered.
$action = $this->current_action();
if ( ! $action )
return;
// security check!
check_admin_referer( 'bulk-' . $this->_args['plural'] );
// Check role
if ( ! current_user_can( 'administrator' ) )
wp_die( 'Security check failed!' );
if ( $action == 'clean' ) {
// If the user wants to clean the elements he/she selected
if(isset($_POST['aDBc_elements_to_process'])){
if(function_exists('is_multisite') && is_multisite()){
// Prepare posts to delete
$posts_to_delete = array();
foreach($_POST['aDBc_elements_to_process'] as $post){
$post_info = explode("|", $post);
$sanitized_site_id = sanitize_html_class($post_info[0]);
$sanitized_item_id = sanitize_html_class($post_info[1]);
// For security, we only proceed if both parts are clean and are numbers
if(is_numeric($sanitized_site_id) && is_numeric($sanitized_item_id)){
if(empty($posts_to_delete[$sanitized_site_id])){
$posts_to_delete[$sanitized_site_id] = array();
}
array_push($posts_to_delete[$sanitized_site_id], $sanitized_item_id);
}
}
// Delete posts
foreach($posts_to_delete as $site_id => $posts_ids){
switch_to_blog($site_id);
global $wpdb;
foreach($posts_ids as $id_post) {
$wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $id_post");
}
restore_current_blog();
}
}else{
global $wpdb;
foreach($_POST['aDBc_elements_to_process'] as $post){
$post_info = explode("|", $post);
$sanitized_id = sanitize_html_class($post_info[1]);
if(is_numeric($sanitized_id)){
$wpdb->query("DELETE FROM $wpdb->posts WHERE ID = " . $sanitized_id);
}
}
}
// Update the message to show to the user
$this->aDBc_message = __("Selected '$this->aDBc_plural_title' successfully cleaned!", "advanced-database-cleaner");
}
}
}
/** Print the page content */
function aDBc_print_page_content(){
include_once 'page_custom_clean.php';
}
}
?>

View File

@@ -0,0 +1,324 @@
<?php
class ADBC_Clean_Transient extends WP_List_Table {
private $aDBc_message = "";
private $aDBc_class_message = "updated";
private $aDBc_elements_to_display = array();
private $aDBc_type_to_clean = "";
private $aDBc_plural_title = "";
private $aDBc_sql_get_transients = "";
private $aDBc_custom_sql_args = "";
private $aDBc_search_sql_arg = "";
private $aDBc_order_by_sql_arg = "";
private $aDBc_limit_offset_sql_arg = "";
/**
* Constructor
*/
function __construct($element_type){
if($element_type == "expired-transients"){
$this->aDBc_type_to_clean = "expired-transients";
$aDBc_singular = __('Expired transient', 'advanced-database-cleaner');
$this->aDBc_plural_title = __('Expired transients', 'advanced-database-cleaner');
$this->aDBc_custom_sql_args = " AND b.option_value < UNIX_TIMESTAMP()";
}
// Prepare additional sql args if any: per page, LIMIT, OFFSET, etc.
if ( ADBC_PLUGIN_PLAN == "pro" ) {
$this->aDBc_search_sql_arg = aDBc_get_search_sql_arg( "a.option_name", "a.option_value" );
}
$this->aDBc_order_by_sql_arg = aDBc_get_order_by_sql_arg( "a.option_id" );
$this->aDBc_limit_offset_sql_arg = aDBc_get_limit_offset_sql_args();
parent::__construct(array(
'singular' => $aDBc_singular,
'plural' => $this->aDBc_plural_title,
'ajax' => false
));
$this->aDBc_prepare_elements_to_clean();
$this->aDBc_print_page_content();
}
/** Prepare elements to display */
function aDBc_prepare_elements_to_clean(){
global $wpdb;
// Process bulk action if any before preparing elements to clean
$this->process_bulk_action();
// Get all elements to clean
if(function_exists('is_multisite') && is_multisite()){
$blogs_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
foreach($blogs_ids as $blog_id){
switch_to_blog($blog_id);
$this->aDBc_fill_array_elements_to_clean($blog_id);
restore_current_blog();
}
}else{
$this->aDBc_fill_array_elements_to_clean("1");
}
// Call WP prepare_items function
$this->prepare_items();
}
/** Fill array elements to display */
function aDBc_fill_array_elements_to_clean($blog_id){
global $wpdb;
// Get all dashboard transients
$this->aDBc_sql_get_transients = "SELECT a.option_id, a.option_name, a.option_value as option_content, a.autoload, b.option_value as option_timeout FROM $wpdb->options a LEFT JOIN $wpdb->options b ON b.option_name =
CONCAT(
CASE WHEN a.option_name LIKE '\_site\_transient\_%'
THEN '_site_transient_timeout_'
ELSE '_transient_timeout_'
END
,
SUBSTRING(a.option_name, CHAR_LENGTH(
CASE WHEN a.option_name LIKE '\_site\_transient\_%'
THEN '_site_transient_'
ELSE '_transient_'
END
) + 1)
)
WHERE (a.option_name LIKE '\_transient\_%' OR a.option_name LIKE '\_site\_transient\_%') AND a.option_name NOT LIKE '%\_transient\_timeout\_%'"
. $this->aDBc_custom_sql_args
. $this->aDBc_search_sql_arg
. $this->aDBc_order_by_sql_arg
//. $this->aDBc_limit_offset_sql_arg
;
$time_now = time();
$aDBc_all_transient_feed = $wpdb->get_results($this->aDBc_sql_get_transients);
foreach($aDBc_all_transient_feed as $aDBc_transient){
// Get timeout of transient
switch ( $this->aDBc_type_to_clean ) {
case "expired-transients" :
$transient_timeout = __( 'Expired', 'advanced-database-cleaner' );
break;
}
// Get transient content
$transient_content = maybe_unserialize($aDBc_transient->option_content);
if(is_array($transient_content)){
$transient_content = "<i>Array</i>";
}elseif(gettype($transient_content) == 'object'){
$transient_content = "<i>Object</i>";
}else{
$transient_content = aDBc_create_tooltip_for_long_string($aDBc_transient->option_content, 35);
}
// Susbst transient name
$transient_name = aDBc_create_tooltip_for_long_string($aDBc_transient->option_name, 35);
array_push($this->aDBc_elements_to_display, array(
'transient_id' => $aDBc_transient->option_id,
'transient_name' => $transient_name,
'transient_content' => $transient_content,
'transient_timeout' => $transient_timeout,
'transient_autoload' => $aDBc_transient->autoload,
'site_id' => $blog_id
)
);
}
}
/** WP: Get columns */
function get_columns(){
$columns = array(
'cb' => '<input type="checkbox" />',
'transient_id' => __('ID','advanced-database-cleaner'),
'transient_name' => __('Transient name','advanced-database-cleaner'),
'transient_content' => __('Value','advanced-database-cleaner'),
'transient_timeout' => __('Expires In','advanced-database-cleaner'),
'transient_autoload' => __('Autoload','advanced-database-cleaner'),
'site_id' => __('Site id','advanced-database-cleaner')
);
return $columns;
}
/** WP: Column default */
function column_default($item, $column_name){
switch($column_name){
case 'transient_id':
case 'transient_name':
case 'transient_content':
case 'transient_timeout':
case 'transient_autoload':
case 'site_id':
return $item[$column_name];
default:
return print_r($item, true) ; //Show the whole array for troubleshooting purposes
}
}
/** WP: Get columns that should be hidden */
function get_hidden_columns(){
// If MU, nothing to hide, else hide Side ID column
if(function_exists('is_multisite') && is_multisite()){
return array();
}else{
return array('site_id');
}
}
function get_sortable_columns() {
$sortable_columns = array(
'transient_id' => array('a.option_id', false), //true means it's already sorted
'transient_name' => array('a.option_name', false)
);
// Since order_by works directly with sql request, we will not order_by in mutlisite since it will not work
if(function_exists('is_multisite') && is_multisite()){
return array();
}else{
return $sortable_columns;
}
}
/** WP: Prepare items to display */
function prepare_items() {
$columns = $this->get_columns();
$hidden = $this->get_hidden_columns();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$per_page = 50;
if(!empty($_GET['per_page'])){
$per_page = absint($_GET['per_page']);
}
$current_page = $this->get_pagenum();
// Prepare sequence of elements to display
$display_data = array_slice($this->aDBc_elements_to_display,(($current_page-1) * $per_page), $per_page);
$this->set_pagination_args( array(
'total_items' => count($this->aDBc_elements_to_display),
'per_page' => $per_page
));
$this->items = $display_data;
}
/** WP: Column cb for check box */
function column_cb($item) {
return sprintf('<input type="checkbox" name="aDBc_elements_to_process[]" value="%s" />', $item['site_id']."|".$item['transient_id']);
}
/** WP: Get bulk actions */
function get_bulk_actions() {
$actions = array(
'clean' => __('Clean','advanced-database-cleaner')
);
return $actions;
}
/** WP: Message to display when no items found */
function no_items() {
_e('No elements found!','advanced-database-cleaner');
}
/** WP: Process bulk actions */
public function process_bulk_action() {
// Detect when a bulk action is being triggered.
$action = $this->current_action();
if ( ! $action )
return;
// security check!
check_admin_referer( 'bulk-' . $this->_args['plural'] );
// Check role
if ( ! current_user_can( 'administrator' ) )
wp_die( 'Security check failed!' );
if ( $action == 'clean' ) {
// If the user wants to clean the elements he/she selected
if(isset($_POST['aDBc_elements_to_process'])){
if(function_exists('is_multisite') && is_multisite()){
// Prepare feeds to delete
$feeds_to_delete = array();
foreach($_POST['aDBc_elements_to_process'] as $aDBc_feed){
$feed_info = explode("|", $aDBc_feed);
$sanitized_site_id = sanitize_html_class($feed_info[0]);
$sanitized_item_id = sanitize_html_class($feed_info[1]);
// For security, we only proceed if both parts are clean and are numbers
if(is_numeric($sanitized_site_id) && is_numeric($sanitized_item_id)){
if(empty($feeds_to_delete[$sanitized_site_id])){
$feeds_to_delete[$sanitized_site_id] = array();
}
array_push($feeds_to_delete[$sanitized_site_id], $sanitized_item_id);
}
}
// Delete feeds
foreach($feeds_to_delete as $site_id => $feed_ids){
switch_to_blog($site_id);
global $wpdb;
$transients_to_delete = $wpdb->get_results("select option_name, option_id from $wpdb->options WHERE option_id IN (" . implode(',',$feed_ids) . ")");
foreach($transients_to_delete as $transient){
$site_wide = (strpos($transient->option_name, '_site_transient') !== false);
$name = str_replace($site_wide ? '_site_transient_' : '_transient_', '', $transient->option_name);
if(false !== $site_wide){
// We used a query directly here instead of delete_site_transient() because in MU, WP tries to delete the transient from sitemeta table, however, in our case, all results above are from options table. So, we need to delete them from options table
$name_timeout = '_site_transient_timeout_' . $name;
$wpdb->query("DELETE FROM $wpdb->options WHERE option_id = {$transient->option_id} OR option_name = '{$name_timeout}'");
}else{
delete_transient($name);
}
}
restore_current_blog();
}
}else{
global $wpdb;
$ids_to_delete = array();
foreach($_POST['aDBc_elements_to_process'] as $aDBc_feed){
$feed_info = explode("|", $aDBc_feed);
$sanitized_id = sanitize_html_class($feed_info[1]);
if(is_numeric($sanitized_id)){
array_push($ids_to_delete, $sanitized_id);
}
}
$names_to_delete = $wpdb->get_col("select option_name from $wpdb->options WHERE option_id IN (" . implode(',',$ids_to_delete) . ")");
foreach($names_to_delete as $transient_name){
$site_wide = (strpos($transient_name, '_site_transient') !== false);
$name = str_replace($site_wide ? '_site_transient_' : '_transient_', '', $transient_name);
if(false !== $site_wide){
// Here, we used delete_site_transient() instead of a query because on a single site, this function will delete the transient from options table
delete_site_transient($name);
}else{
delete_transient($name);
}
}
}
// Update the message to show to the user
$this->aDBc_message = __("Selected 'Transients' successfully cleaned!", "advanced-database-cleaner");
}
}
}
/** Print the page content */
function aDBc_print_page_content(){
include_once 'page_custom_clean.php';
}
}
?>

View File

@@ -0,0 +1,160 @@
<!-- style et code ok -->
<div class="aDBc-float-left aDBc-margin-t-10">
<a href="?page=advanced_db_cleaner&aDBc_tab=general" style="text-decoration:none">
<span class="dashicons dashicons-controls-back aDBc-back-dashicon"></span>
<span style="vertical-align:middle"><?php echo __( 'Return', 'advanced-database-cleaner' ); ?></span>
</a>
</div>
<div>
<div class="aDBc-custom-clean-text">
<?php
echo __( 'Custom cleanup of', 'advanced-database-cleaner' ) . " ";
echo "<strong>" . $this->aDBc_plural_title . "</strong> - ";
echo __( 'Total Found', 'advanced-database-cleaner' ) . " : ";
echo "<b><span class='aDBc-custom-total'>" . count( $this->aDBc_elements_to_display ) . "</span></b>";
?>
</div>
<div class="aDBc-filter-container">
<div class="aDBc-filter-section">
<span class="aDBc-premium-tooltip">
<?php
$free_style = "";
if ( ADBC_PLUGIN_PLAN == "free" ) {
$free_style = "aDBc-filter-pro-only";
}
?>
<form class="<?php echo $free_style; ?>" method="get">
<?php
// Generate current parameters in URL
foreach ( $_GET as $name => $value ) {
if ( $name != "s" && $name != "in" && $name != "paged" ) {
$name = esc_attr( sanitize_text_field( $name ) );
$value = esc_attr( sanitize_text_field( $value ) );
echo "<input type='hidden' name='$name' value='$value'/>";
}
}
// Return paged to page 1
echo "<input type='hidden' name='paged' value='1'/>";
?>
<input class="aDBc-filter-search-input" type="search" placeholder="<?php _e( 'Search for', 'advanced-database-cleaner' ); ?>" name="s" value="<?php echo empty( $_GET['s'] ) ? '' : esc_attr( $_GET['s'] ); ?>"/>
<div class="aDBc-custom-filter-radio-section">
<span style="padding:0px 10px"><?php _e( 'Search in', 'advanced-database-cleaner' ); ?></span>
<?php
$in_checked = empty( $_GET['in'] ) || ( ! empty( $_GET['in'] ) && $_GET['in'] == "key" ) ? 'checked' : '';
$value_checked = ! empty( $_GET['in'] ) && $_GET['in'] == "value" ? 'checked' : '';
?>
<input type="radio" name="in" value="key" checked <?php echo $in_checked; ?>><?php _e( 'Name', 'advanced-database-cleaner' ); ?> &nbsp;
<input type="radio" name="in" value="value" <?php echo $value_checked; ?>><?php _e( 'Value', 'advanced-database-cleaner' ); ?>
</div>
<input class="button-secondary aDBc-filter-botton" type="submit" value="<?php _e( 'Filter', 'advanced-database-cleaner' ); ?>"/>
</form>
<?php
if ( ADBC_PLUGIN_PLAN == "free" ) {
?>
<span style="width:150px" class="aDBc-premium-tooltiptext">
<a href="https://sigmaplugin.com/downloads/wordpress-advanced-database-cleaner/" target="_blank">
<?php _e( 'Available in Pro version!', 'advanced-database-cleaner' ); ?>
</a>
</span>
<?php
}
?>
</span>
</div>
<!-- Items per page -->
<div class="aDBc-items-per-page">
<form method="get">
<?php
// Generate current parameters in URL
foreach ( $_GET as $name => $value ) {
if ( $name != "per_page" && $name != "paged" ) {
$name = esc_attr( sanitize_text_field( $name ) );
$value = esc_attr( sanitize_text_field( $value ) );
echo "<input type='hidden' name='$name' value='$value'/>";
}
}
// Return paged to page 1
echo "<input type='hidden' name='paged' value='1'/>";
?>
<span class="aDBc-items-per-page-label">
<?php _e( 'Items per page', 'advanced-database-cleaner' ); ?>
</span>
<input name="per_page" class="aDBc-items-per-page-input" type="number" value="<?php echo empty( $_GET['per_page'] ) ? '50' : esc_attr( $_GET['per_page'] ); ?>"/>
<input type="submit" class="button-secondary aDBc-show-botton" value="<?php _e( 'Show', 'advanced-database-cleaner' ); ?>"/>
</form>
</div>
<?php
if ( ( ! empty( $_GET['s'] ) && trim( $_GET['s'] ) != "" ) ||
! empty( $_GET['in'] )
) {
// Remove args to delete custom filter
$aDBc_new_URI = $_SERVER['REQUEST_URI'];
$aDBc_new_URI = remove_query_arg( array( 's', 'in' ), $aDBc_new_URI );
?>
<div class="aDBc-delete-custom-filter">
<a style="color:red" href="<?php echo esc_url( $aDBc_new_URI ); ?>">
<?php _e( 'Delete custom filter', 'advanced-database-cleaner' ); ?>
</a>
</div>
<?php
}
?>
</div>
</div>

View File

@@ -0,0 +1,22 @@
<?php
// Print a message if any
if($this->aDBc_message != ""){
echo '<div id="aDBc_message" class="' . $this->aDBc_class_message . ' notice is-dismissible"><p>' . $this->aDBc_message . '</p></div>';
}
?>
<div class="aDBc-content-max-width">
<?php include_once 'header_page_custom_clean.php'; ?>
<div>
<form id="aDBc_form" action="" method="post">
<?php
// Print the elements to clean
$this->display();
?>
</form>
</div>
</div>