Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/advanced.../admin/includes
File: class-post-list.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Advanced_Ads\Admin;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* Display ad-related information on the post and page overview page.
[5] Fix | Delete
*/
[6] Fix | Delete
class Post_List {
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Register filters
[10] Fix | Delete
*/
[11] Fix | Delete
public function __construct() {
[12] Fix | Delete
add_action( 'restrict_manage_posts', [ $this, 'add_ads_filter_dropdown' ] );
[13] Fix | Delete
add_action( 'pre_get_posts', [ $this, 'filter_posts_by_ads_status' ] );
[14] Fix | Delete
add_filter( 'manage_posts_columns', [ $this, 'ads_column_init' ] );
[15] Fix | Delete
add_filter( 'manage_pages_columns', [ $this, 'ads_column_init' ] );
[16] Fix | Delete
add_action( 'manage_posts_custom_column', [ $this, 'ads_column_content' ], 10, 2 );
[17] Fix | Delete
add_action( 'manage_pages_custom_column', [ $this, 'ads_column_content' ], 10, 2 );
[18] Fix | Delete
add_filter( 'default_hidden_columns', [ $this, 'hide_ads_column_by_default' ], 10, 2 );
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Add a filter dropdown to the post and pages lists.
[23] Fix | Delete
*
[24] Fix | Delete
* @param string $post_type current post type.
[25] Fix | Delete
*
[26] Fix | Delete
* @return void
[27] Fix | Delete
*/
[28] Fix | Delete
public function add_ads_filter_dropdown( string $post_type ): void {
[29] Fix | Delete
if ( ! in_array( $post_type, [ 'post', 'page' ], true ) ) {
[30] Fix | Delete
return;
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
$viewability = $_GET['ad-viewability'] ?? '';
[34] Fix | Delete
include ADVADS_ABSPATH . 'admin/views/post-list-filter-dropdown.php';
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* Filter the list of posts and pages based on their ads settings
[39] Fix | Delete
*
[40] Fix | Delete
* @param \WP_Query $query The WP_Query object.
[41] Fix | Delete
*
[42] Fix | Delete
* @return void
[43] Fix | Delete
*/
[44] Fix | Delete
public function filter_posts_by_ads_status( \WP_Query $query ): void {
[45] Fix | Delete
if ( ! is_admin() || ! $query->is_main_query() || ! $query->get( 'post_type' ) || ! in_array( $query->get( 'post_type' ), [ 'post', 'page' ], true ) ) {
[46] Fix | Delete
return;
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
$viewability = $_GET['ad-viewability'] ?? '';
[50] Fix | Delete
if ( ! $viewability ) {
[51] Fix | Delete
return;
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
if ( in_array( $viewability, [ 'disable_ads', 'disable_the_content' ], true ) ) {
[55] Fix | Delete
$query->set( 'meta_key', '_advads_ad_settings' );
[56] Fix | Delete
$query->set( 'meta_compare', 'LIKE' );
[57] Fix | Delete
$query->set( 'meta_value', '"' . $viewability . '";i:1;' );
[58] Fix | Delete
}
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Adds a new column to the post overview page for public post types.
[63] Fix | Delete
*
[64] Fix | Delete
* @param array $columns An array of column names.
[65] Fix | Delete
*
[66] Fix | Delete
* @return array The modified array of column names.
[67] Fix | Delete
*/
[68] Fix | Delete
public function ads_column_init( array $columns ): array {
[69] Fix | Delete
$post_type_object = get_post_type_object( get_current_screen()->post_type );
[70] Fix | Delete
[71] Fix | Delete
if ( ! $post_type_object->public ) {
[72] Fix | Delete
return $columns;
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
$columns['ad-status'] = __( 'Ad injection', 'advanced-ads' );
[76] Fix | Delete
[77] Fix | Delete
return $columns;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
/**
[81] Fix | Delete
* Displays the value of the "ads" post meta in the "Ads" column.
[82] Fix | Delete
*
[83] Fix | Delete
* @param string $column The name of the column.
[84] Fix | Delete
* @param int $post_id The ID of the post.
[85] Fix | Delete
*
[86] Fix | Delete
* @return void
[87] Fix | Delete
*/
[88] Fix | Delete
public function ads_column_content( string $column, int $post_id ): void {
[89] Fix | Delete
if ( $column !== 'ad-status' ) {
[90] Fix | Delete
return;
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
$ads_post_meta = get_post_meta( $post_id, '_advads_ad_settings', true );
[94] Fix | Delete
[95] Fix | Delete
if ( ! empty( $ads_post_meta['disable_ads'] ) ) {
[96] Fix | Delete
echo '<p>' . esc_html__( 'All ads disabled', 'advanced-ads' ) . '</p>';
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
if ( defined( 'AAP_VERSION' ) && ! empty( $ads_post_meta['disable_the_content'] ) ) {
[100] Fix | Delete
echo '<p>' . esc_html__( 'Ads in content disabled', 'advanced-ads' ) . '</p>';
[101] Fix | Delete
}
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* Hide the Ads column by default
[106] Fix | Delete
*
[107] Fix | Delete
* @param string[] $hidden hidden columns.
[108] Fix | Delete
* @param \WP_Screen $screen screen object.
[109] Fix | Delete
*
[110] Fix | Delete
* @return string[]
[111] Fix | Delete
*/
[112] Fix | Delete
public function hide_ads_column_by_default( array $hidden, \WP_Screen $screen ): array {
[113] Fix | Delete
$post_type_object = get_post_type_object( $screen->post_type );
[114] Fix | Delete
[115] Fix | Delete
if ( ! $post_type_object || ! $post_type_object->public ) {
[116] Fix | Delete
return $hidden;
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
$hidden[] = 'ad-status';
[120] Fix | Delete
[121] Fix | Delete
return $hidden;
[122] Fix | Delete
}
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
[126] Fix | Delete
[127] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function