nirjharlo /
complete-google-seo-scan
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace NirjharLo\Cgss\Src; |
||||||
| 4 | |||||||
| 5 | if ( ! defined( 'ABSPATH' ) ) exit; |
||||||
| 6 | |||||||
| 7 | use \NirjharLo\Cgss\Lib\Table; |
||||||
|
0 ignored issues
–
show
|
|||||||
| 8 | use \NirjharLo\Cgss\Lib\OverviewTable; |
||||||
|
0 ignored issues
–
show
The type
\NirjharLo\Cgss\Lib\OverviewTable was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 9 | |||||||
| 10 | |||||||
| 11 | /** |
||||||
| 12 | * Backend settings page class, can have settings fields or data table |
||||||
| 13 | */ |
||||||
| 14 | |||||||
| 15 | final class Settings { |
||||||
| 16 | |||||||
| 17 | public $capability; |
||||||
| 18 | public $menuPage; |
||||||
| 19 | public $subMenuPage; |
||||||
| 20 | public $subMenuPageCpt; |
||||||
| 21 | public $help; |
||||||
| 22 | public $screen; |
||||||
| 23 | |||||||
| 24 | // Add basic actions for menu and settings |
||||||
| 25 | public function __construct() { |
||||||
| 26 | |||||||
| 27 | $this->capability = 'manage_options'; |
||||||
| 28 | $this->menuPage = array( |
||||||
| 29 | 'name' => __( 'SEO Scan', 'cgss' ), |
||||||
|
0 ignored issues
–
show
The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 30 | 'heading' => __( 'SEO Scan', 'cgss' ), |
||||||
| 31 | 'slug' => 'seo-scan' |
||||||
| 32 | ); |
||||||
| 33 | $this->subMenuPage = array( |
||||||
| 34 | 'name' => __( 'Seo Scan Overview', 'cgss' ), |
||||||
| 35 | 'heading' => __( 'Overview', 'cgss' ), |
||||||
| 36 | 'slug' => 'seo-scan', |
||||||
| 37 | 'parent_slug' => 'seo-scan', |
||||||
| 38 | 'help' => false, |
||||||
| 39 | 'screen' => true |
||||||
| 40 | ); |
||||||
| 41 | $this->subMenuPageCpt = $this->get_post_type_menus(); |
||||||
| 42 | |||||||
| 43 | $this->screen = ''; // true/false |
||||||
| 44 | |||||||
| 45 | add_action( 'admin_menu', array( $this, 'menu_page' ) ); |
||||||
|
0 ignored issues
–
show
The function
add_action was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 46 | add_action( 'admin_menu', array( $this, 'sub_menu_page' ) ); |
||||||
| 47 | add_action( 'admin_menu', array( $this, 'cpt_sub_menu_page' ) ); |
||||||
| 48 | add_filter( 'set-screen-option', array( $this, 'set_screen' ), 10, 3 ); |
||||||
|
0 ignored issues
–
show
The function
add_filter was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 49 | add_filter('screen_options_show_screen', array( $this, 'remove_screen_options')); |
||||||
| 50 | } |
||||||
| 51 | |||||||
| 52 | |||||||
| 53 | public function remove_screen_options() { |
||||||
| 54 | |||||||
| 55 | if (isset($_GET['page']) && $_GET['page'] == 'seo-scan') { |
||||||
| 56 | return false; |
||||||
| 57 | } else { |
||||||
| 58 | return true; |
||||||
| 59 | } |
||||||
| 60 | } |
||||||
| 61 | |||||||
| 62 | // Get post type data to form menu variables |
||||||
| 63 | public function get_post_type_menus() { |
||||||
| 64 | |||||||
| 65 | $menu_vars = array(); |
||||||
| 66 | |||||||
| 67 | $post_types = get_post_types( array( 'public' => true, ), 'names' ); |
||||||
|
0 ignored issues
–
show
The function
get_post_types was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 68 | unset( $post_types['attachment'] ); |
||||||
| 69 | |||||||
| 70 | foreach ( $post_types as $type ) { |
||||||
| 71 | |||||||
| 72 | $count_posts = wp_count_posts( $type ); |
||||||
|
0 ignored issues
–
show
The function
wp_count_posts was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 73 | if ( $count_posts->publish > 0 ) { |
||||||
| 74 | |||||||
| 75 | $type_name = ucwords( get_post_type_object( $type )->labels->singular_name ); |
||||||
|
0 ignored issues
–
show
The function
get_post_type_object was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 76 | $menu_vars[] = array( |
||||||
| 77 | 'name' => $type_name . ' ' . __( 'Seo Scan', 'cgss' ), |
||||||
|
0 ignored issues
–
show
The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 78 | 'heading' => $type_name, |
||||||
| 79 | 'slug' => 'seo-scan-' . $type, |
||||||
| 80 | 'parent_slug' => 'seo-scan', |
||||||
| 81 | 'help' => false, |
||||||
| 82 | 'screen' => true |
||||||
| 83 | ); |
||||||
| 84 | } |
||||||
| 85 | } |
||||||
| 86 | |||||||
| 87 | return $menu_vars; |
||||||
| 88 | } |
||||||
| 89 | |||||||
| 90 | |||||||
| 91 | // Add main menu page callback |
||||||
| 92 | public function menu_page() { |
||||||
| 93 | |||||||
| 94 | if ($this->menuPage) { |
||||||
|
0 ignored issues
–
show
The expression
$this->menuPage of type array<string,mixed|string> is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||||||
| 95 | add_menu_page( |
||||||
|
0 ignored issues
–
show
The function
add_menu_page was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 96 | $this->menuPage['name'], |
||||||
| 97 | $this->menuPage['heading'], |
||||||
| 98 | $this->capability, |
||||||
| 99 | $this->menuPage['slug'], |
||||||
| 100 | array( $this, 'overview_content_cb' ), |
||||||
| 101 | 'dashicons-search' |
||||||
| 102 | ); |
||||||
| 103 | } |
||||||
| 104 | } |
||||||
| 105 | |||||||
| 106 | |||||||
| 107 | |||||||
| 108 | //Add a Submenu page callback |
||||||
| 109 | public function sub_menu_page() { |
||||||
| 110 | |||||||
| 111 | if ($this->subMenuPage) { |
||||||
|
0 ignored issues
–
show
The expression
$this->subMenuPage of type array<string,boolean|mixed|string> is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||||||
| 112 | $hook = add_submenu_page( |
||||||
|
0 ignored issues
–
show
The function
add_submenu_page was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 113 | $this->subMenuPage['parent_slug'], |
||||||
| 114 | $this->subMenuPage['name'], |
||||||
| 115 | $this->subMenuPage['heading'], |
||||||
| 116 | $this->capability, |
||||||
| 117 | $this->subMenuPage['slug'], |
||||||
| 118 | array( $this, 'overview_content_cb' ) |
||||||
| 119 | ); |
||||||
| 120 | if ($this->subMenuPage['screen']) { |
||||||
| 121 | add_action( 'load-' . $hook, array( $this, 'overview_screen_option' ) ); |
||||||
|
0 ignored issues
–
show
The function
add_action was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 122 | } |
||||||
| 123 | } |
||||||
| 124 | } |
||||||
| 125 | |||||||
| 126 | |||||||
| 127 | |||||||
| 128 | // Add Submenu page callback for cpts |
||||||
| 129 | public function cpt_sub_menu_page() { |
||||||
| 130 | |||||||
| 131 | if ($this->subMenuPageCpt) { |
||||||
| 132 | foreach ($this->subMenuPageCpt as $value) { |
||||||
| 133 | $hook = add_submenu_page( |
||||||
|
0 ignored issues
–
show
The function
add_submenu_page was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 134 | $value['parent_slug'], |
||||||
| 135 | $value['name'], |
||||||
| 136 | $value['heading'], |
||||||
| 137 | $this->capability, |
||||||
| 138 | $value['slug'], |
||||||
| 139 | array( $this, 'cpt_content_cb' ) |
||||||
| 140 | ); |
||||||
| 141 | if ($value['screen']) { |
||||||
| 142 | add_action( 'load-' . $hook, array( $this, 'screen_option' ) ); |
||||||
|
0 ignored issues
–
show
The function
add_action was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 143 | } |
||||||
| 144 | } |
||||||
| 145 | } |
||||||
| 146 | } |
||||||
| 147 | |||||||
| 148 | |||||||
| 149 | |||||||
| 150 | //Set screen option |
||||||
| 151 | public function set_screen($status, $option, $value) { |
||||||
| 152 | |||||||
| 153 | if ( 'post_per_page' == $option ) return $value; // Related to PLUGIN_TABLE() |
||||||
| 154 | //return $status; |
||||||
| 155 | } |
||||||
| 156 | |||||||
| 157 | |||||||
| 158 | |||||||
| 159 | //Set screen option for Items table |
||||||
| 160 | public function overview_screen_option() { |
||||||
| 161 | |||||||
| 162 | $this->overview = new OverviewTable(); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 163 | } |
||||||
| 164 | |||||||
| 165 | |||||||
| 166 | |||||||
| 167 | //Set screen option for Items table |
||||||
| 168 | public function screen_option() { |
||||||
| 169 | |||||||
| 170 | $option = 'per_page'; |
||||||
| 171 | $args = array( |
||||||
| 172 | 'label' => __( 'Show per page', 'cgss' ), |
||||||
|
0 ignored issues
–
show
The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 173 | 'default' => 10, |
||||||
| 174 | 'option' => 'post_per_page' // Related to TABLE() |
||||||
| 175 | ); |
||||||
| 176 | add_screen_option( $option, $args ); |
||||||
|
0 ignored issues
–
show
The function
add_screen_option was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 177 | $this->table = new Table(); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 178 | } |
||||||
| 179 | |||||||
| 180 | |||||||
| 181 | |||||||
| 182 | // Menu page callback |
||||||
| 183 | public function overview_content_cb() { ?> |
||||||
| 184 | |||||||
| 185 | <div class="wrap"> |
||||||
| 186 | <h1><?php echo get_admin_page_title(); ?> |
||||||
|
0 ignored issues
–
show
The function
get_admin_page_title was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 187 | |
||||||
| 188 | <a href="?page=seo-scan&fetch=true" class="button button-secondary"> |
||||||
| 189 | <?php _e( 'Fetch Insight', 'cgss' ); ?> |
||||||
|
0 ignored issues
–
show
The function
_e was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 190 | </a> |
||||||
| 191 | </h1> |
||||||
| 192 | <br class="clear"> |
||||||
| 193 | <?php if (isset($_GET['fetch'])) : ?> |
||||||
| 194 | <?php do_action( 'cgss_fetch_insight' ); ?> |
||||||
|
0 ignored issues
–
show
The function
do_action was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 195 | <?php endif; ?> |
||||||
| 196 | <?php |
||||||
| 197 | // Source: /lib/overview-table.php |
||||||
| 198 | $this->overview = new OverviewTable(); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 199 | $this->overview->prepare_items(); |
||||||
| 200 | $this->overview->display(); |
||||||
| 201 | ?> |
||||||
| 202 | <br class="clear"> |
||||||
| 203 | </div> |
||||||
| 204 | <?php |
||||||
| 205 | } |
||||||
| 206 | |||||||
| 207 | |||||||
| 208 | |||||||
| 209 | // Add submenu page callback |
||||||
| 210 | public function cpt_content_cb() { ?> |
||||||
| 211 | |||||||
| 212 | <div class="wrap"> |
||||||
| 213 | <h1><?php echo get_admin_page_title(); ?></h1> |
||||||
|
0 ignored issues
–
show
The function
get_admin_page_title was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 214 | <br class="clear"> |
||||||
| 215 | <?php if (isset($_GET['scan'])) : ?> |
||||||
| 216 | <?php do_action( 'cgss_scan' ); ?> |
||||||
|
0 ignored issues
–
show
The function
do_action was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 217 | <?php elseif (isset($_GET['compete'])) : ?> |
||||||
| 218 | <?php do_action( 'cgss_compete' ); ?> |
||||||
| 219 | <?php else : ?> |
||||||
| 220 | <form method="post" action=""> |
||||||
| 221 | <?php |
||||||
| 222 | // Source: /lib/table.php |
||||||
| 223 | $this->table = new Table(); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 224 | $this->table->prepare_items(); |
||||||
| 225 | $this->table->display(); |
||||||
| 226 | ?> |
||||||
| 227 | </form> |
||||||
| 228 | <?php endif; ?> |
||||||
| 229 | <br class="clear"> |
||||||
| 230 | </div> |
||||||
| 231 | <?php |
||||||
| 232 | } |
||||||
| 233 | } ?> |
||||||
| 234 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths