| 1 |
<?php |
| 2 |
/* |
| 3 |
* License: GPLv3 |
| 4 |
* License URI: https://www.gnu.org/licenses/gpl.txt |
| 5 |
* Copyright 2012-2026 Jean-Sebastien Morisset (https://wpsso.com/) |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
|
| 10 |
die( 'These aren\'t the droids you\'re looking for.' ); |
| 11 |
} |
| 12 |
|
| 13 |
if ( ! defined( 'WPSSO_PLUGINDIR' ) ) { |
| 14 |
|
| 15 |
die( 'Do. Or do not. There is no try.' ); |
| 16 |
} |
| 17 |
|
| 18 |
if ( ! class_exists( 'WpssoAdminHeadSuggest' ) ) { |
| 19 |
|
| 20 |
class WpssoAdminHeadSuggest { |
| 21 |
|
| 22 |
private $p; // Wpsso class object. |
| 23 |
|
| 24 |
/* |
| 25 |
* Instantiated by WpssoAdminHead->__construct(). |
| 26 |
*/ |
| 27 |
public function __construct( &$plugin ) { |
| 28 |
|
| 29 |
$this->p =& $plugin; |
| 30 |
|
| 31 |
if ( $this->p->debug->enabled ) { |
| 32 |
|
| 33 |
$this->p->debug->mark(); |
| 34 |
} |
| 35 |
|
| 36 |
add_action( 'admin_head', array( $this, 'suggest' ), 100, 0 ); |
| 37 |
} |
| 38 |
|
| 39 |
public function suggest( $suggest_max = 2 ) { |
| 40 |
|
| 41 |
if ( $this->p->debug->enabled ) { |
| 42 |
|
| 43 |
$this->p->debug->log_args( array( |
| 44 |
'suggest_max' => $suggest_max, |
| 45 |
) ); |
| 46 |
} |
| 47 |
|
| 48 |
$suggested = 0; |
| 49 |
|
| 50 |
/* |
| 51 |
* Suggest options, addons, and attributes, in that order. |
| 52 |
*/ |
| 53 |
foreach ( array( 'options', 'addons', 'attributes' ) as $suffix ) { |
| 54 |
|
| 55 |
require_once WPSSO_PLUGINDIR . 'lib/admin-head-suggest-' . $suffix . '.php'; |
| 56 |
|
| 57 |
$classname = 'wpssoadminheadsuggest' . $suffix; |
| 58 |
$suggest_obj = new $classname( $this->p ); |
| 59 |
$suggested = $suggested + $suggest_obj->suggest( $suggest_max - $suggested ); |
| 60 |
|
| 61 |
if ( $suggested >= $suggest_max ) break; |
| 62 |
} |
| 63 |
|
| 64 |
if ( $this->p->debug->enabled ) { |
| 65 |
|
| 66 |
$this->p->debug->log( 'return suggested = ' . $suggested ); |
| 67 |
} |
| 68 |
|
| 69 |
return $suggested; |
| 70 |
} |
| 71 |
} |
| 72 |
} |
| 73 |
|