| 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( 'WpssoStyle' ) ) { |
| 19 |
|
| 20 |
class WpssoStyle { |
| 21 |
|
| 22 |
private $p; // Wpsso class object. |
| 23 |
private $doing_dev = false; |
| 24 |
private $file_ext = 'min.css'; |
| 25 |
private $version = ''; |
| 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 |
$this->doing_dev = SucomUtilWP::doing_dev(); |
| 37 |
$this->file_ext = $this->doing_dev ? 'css' : 'min.css'; |
| 38 |
$this->version = WpssoConfig::get_version() . ( $this->doing_dev ? gmdate( '-ymd-His' ) : '' ); |
| 39 |
|
| 40 |
if ( is_admin() ) { |
| 41 |
|
| 42 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_styles' ), WPSSO_ADMIN_SCRIPTS_PRIORITY ); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
public function admin_enqueue_styles( $hook_name ) { |
| 47 |
|
| 48 |
if ( $this->p->debug->enabled ) { |
| 49 |
|
| 50 |
$this->p->debug->log( 'hook name = ' . $hook_name ); |
| 51 |
$this->p->debug->log( 'screen base = ' . SucomUtilWP::get_screen_base() ); |
| 52 |
} |
| 53 |
|
| 54 |
/* |
| 55 |
* Required for the datepicker popup. |
| 56 |
* |
| 57 |
* See https://developers.google.com/speed/libraries/. |
| 58 |
*/ |
| 59 |
$jquery_ui_version = $this->p->cf[ 'jquery-ui' ][ 'version' ]; |
| 60 |
$jquery_ui_version = apply_filters( 'wpsso_jquery_ui_version', $jquery_ui_version ); |
| 61 |
$jquery_ui_url = 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $jquery_ui_version . '/themes/smoothness/jquery-ui.css'; |
| 62 |
$cached_url = $this->p->cache->get( $jquery_ui_url, $format = 'url', $cache_type = 'file', WEEK_IN_SECONDS ); |
| 63 |
|
| 64 |
wp_register_style( 'jquery-ui.js', $cached_url, $deps = array(), $this->p->cf[ 'jquery-ui' ][ 'version' ] ); |
| 65 |
|
| 66 |
/* |
| 67 |
* Register styles for option help popup. |
| 68 |
* |
| 69 |
* See http://qtip2.com/download. |
| 70 |
*/ |
| 71 |
wp_register_style( 'jquery-qtip.js', WPSSO_URLPATH . 'css/ext/jquery-qtip.' . $this->file_ext, |
| 72 |
$deps = array(), $this->p->cf[ 'jquery-qtip' ][ 'version' ] ); |
| 73 |
|
| 74 |
/* |
| 75 |
* Register styles for settings pages. |
| 76 |
*/ |
| 77 |
wp_register_style( 'sucom-settings-page', WPSSO_URLPATH . 'css/com/settings-page.' . $this->file_ext, |
| 78 |
$deps = array(), $this->version ); |
| 79 |
|
| 80 |
/* |
| 81 |
* Register styles for settings tables. |
| 82 |
*/ |
| 83 |
wp_register_style( 'sucom-settings-table', WPSSO_URLPATH . 'css/com/settings-table.' . $this->file_ext, |
| 84 |
$deps = array(), $this->version ); |
| 85 |
|
| 86 |
/* |
| 87 |
* Register styles for metabox tabs. |
| 88 |
*/ |
| 89 |
wp_register_style( 'sucom-metabox-tabs', WPSSO_URLPATH . 'css/com/metabox-tabs.' . $this->file_ext, |
| 90 |
$deps = array( 'wp-color-picker' ), $this->version ); |
| 91 |
|
| 92 |
/* |
| 93 |
* Only load stylesheets we need. |
| 94 |
*/ |
| 95 |
switch ( $hook_name ) { |
| 96 |
|
| 97 |
/* |
| 98 |
* Addons and license settings page. |
| 99 |
*/ |
| 100 |
case ( preg_match( '/_page_wpsso-.*(addons|licenses)/', $hook_name ) ? true : false ): |
| 101 |
|
| 102 |
if ( $this->p->debug->enabled ) { |
| 103 |
|
| 104 |
$this->p->debug->log( 'enqueuing styles for addons and licenses page' ); |
| 105 |
} |
| 106 |
|
| 107 |
add_filter( 'admin_body_class', array( $this, 'add_plugins_body_class' ) ); |
| 108 |
|
| 109 |
// no break |
| 110 |
|
| 111 |
/* |
| 112 |
* Any settings page. Also matches the profile_page and users_page hooks. |
| 113 |
*/ |
| 114 |
case ( false !== strpos( $hook_name, '_page_wpsso-' ) ? true : false ): |
| 115 |
|
| 116 |
if ( $this->p->debug->enabled ) { |
| 117 |
|
| 118 |
$this->p->debug->log( 'enqueuing styles for settings page' ); |
| 119 |
} |
| 120 |
|
| 121 |
wp_enqueue_style( 'sucom-settings-page' ); |
| 122 |
|
| 123 |
// No break. |
| 124 |
|
| 125 |
/* |
| 126 |
* Editing page. |
| 127 |
*/ |
| 128 |
case 'post.php': // Post edit. |
| 129 |
case 'post-new.php': // Post edit. |
| 130 |
case 'term.php': // Term edit. |
| 131 |
case 'edit-tags.php': // Term edit. |
| 132 |
case 'user-edit.php': // User edit. |
| 133 |
case 'profile.php': // User edit. |
| 134 |
case ( SucomUtilWP::is_toplevel_edit( $hook_name ) ): // Required for event espresso plugin. |
| 135 |
|
| 136 |
if ( $this->p->debug->enabled ) { |
| 137 |
|
| 138 |
$this->p->debug->log( 'enqueuing styles for editing page' ); |
| 139 |
} |
| 140 |
|
| 141 |
wp_enqueue_style( 'jquery-ui.js' ); |
| 142 |
wp_enqueue_style( 'jquery-qtip.js' ); |
| 143 |
wp_enqueue_style( 'sucom-settings-table' ); |
| 144 |
wp_enqueue_style( 'sucom-metabox-tabs' ); |
| 145 |
|
| 146 |
break; // Stop here. |
| 147 |
|
| 148 |
case 'plugin-install.php': |
| 149 |
|
| 150 |
if ( isset( $_GET[ 'plugin' ] ) ) { |
| 151 |
|
| 152 |
/* |
| 153 |
* See wordpress/wp-admin/plugins.php line 21. |
| 154 |
*/ |
| 155 |
$plugin_slug = wp_unslash( $_GET[ 'plugin' ] ); |
| 156 |
|
| 157 |
if ( isset( $this->p->cf[ '*' ][ 'slug' ][ $plugin_slug ] ) ) { |
| 158 |
|
| 159 |
if ( $this->p->debug->enabled ) { |
| 160 |
|
| 161 |
$this->p->debug->log( 'enqueuing styles for plugin install page' ); |
| 162 |
} |
| 163 |
|
| 164 |
$this->plugin_install_inline_style( $hook_name, $plugin_slug ); |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
break; // Stop here. |
| 169 |
} |
| 170 |
|
| 171 |
$this->admin_register_page_styles( $hook_name ); |
| 172 |
|
| 173 |
$this->admin_enqueue_page_styles( $hook_name ); |
| 174 |
} |
| 175 |
|
| 176 |
public function add_plugins_body_class( $classes ) { |
| 177 |
|
| 178 |
$classes .= ' plugins-php'; |
| 179 |
|
| 180 |
return $classes; |
| 181 |
} |
| 182 |
|
| 183 |
private function admin_register_page_styles( $hook_name ) { |
| 184 |
|
| 185 |
if ( $this->p->debug->enabled ) { |
| 186 |
|
| 187 |
$this->p->debug->mark(); |
| 188 |
} |
| 189 |
|
| 190 |
$filter_name = 'wpsso_admin_page_style_css'; |
| 191 |
$filter_ids = SucomUtilWP::get_filter_hook_ids( $filter_name ); |
| 192 |
$sortable_cols = WpssoAbstractWpMeta::get_sortable_columns(); // Uses a local cache. |
| 193 |
|
| 194 |
$cache_md5_pre = 'wpsso_'; |
| 195 |
$cache_exp_filter = 'wpsso_cache_expire_admin_css'; |
| 196 |
$cache_exp_secs = (int) apply_filters( $cache_exp_filter, DAY_IN_SECONDS ); |
| 197 |
|
| 198 |
$cache_salt = __METHOD__ . '('; |
| 199 |
$cache_salt .= '_version:' . $this->version; |
| 200 |
$cache_salt .= '_filters:' . implode( ',', array_keys( $filter_ids ) ); |
| 201 |
$cache_salt .= '_columns:' . implode( ',', array_keys( $sortable_cols ) ); |
| 202 |
$cache_salt .= ')'; |
| 203 |
$cache_id = $cache_md5_pre . md5( $cache_salt ); |
| 204 |
|
| 205 |
if ( $this->p->debug->enabled ) { |
| 206 |
|
| 207 |
$this->p->debug->log( 'enqueueing style sucom-admin-page' ); |
| 208 |
} |
| 209 |
|
| 210 |
wp_register_style( 'sucom-admin-page', WPSSO_URLPATH . 'css/com/admin-page.' . $this->file_ext, $deps = array(), $this->version ); |
| 211 |
|
| 212 |
if ( ! $this->doing_dev ) { |
| 213 |
|
| 214 |
if ( $custom_style_css = get_transient( $cache_id ) ) { // Not empty. |
| 215 |
|
| 216 |
if ( $this->p->debug->enabled ) { |
| 217 |
|
| 218 |
$this->p->debug->log( 'adding sucom-admin-page inline style from cache' ); |
| 219 |
} |
| 220 |
|
| 221 |
wp_add_inline_style( 'sucom-admin-page', $custom_style_css ); |
| 222 |
|
| 223 |
return; |
| 224 |
} |
| 225 |
} |
| 226 |
|
| 227 |
if ( $this->p->debug->enabled ) { |
| 228 |
|
| 229 |
$this->p->debug->mark( 'create and minify admin page style' ); // Begin timer. |
| 230 |
} |
| 231 |
|
| 232 |
global $_registered_pages; // Should be an array, but could be null. |
| 233 |
|
| 234 |
$menu_pagehook = is_array( $_registered_pages ) ? // Just in case. |
| 235 |
key( SucomUtil::preg_grep_keys( '/^toplevel_page_wpsso-/', $_registered_pages ) ) : ''; |
| 236 |
|
| 237 |
$metabox_id = $this->p->cf[ 'meta' ][ 'id' ]; |
| 238 |
|
| 239 |
/* |
| 240 |
* Fonts. |
| 241 |
*/ |
| 242 |
$custom_style_css = ' |
| 243 |
@font-face { |
| 244 |
font-family:"WpssoIcons"; |
| 245 |
font-weight:normal; |
| 246 |
font-style:normal; |
| 247 |
src:url("' . WPSSO_URLPATH . 'fonts/icons.eot?' . $this->version . '"); |
| 248 |
src:url("' . WPSSO_URLPATH . 'fonts/icons.eot?' . $this->version . '#iefix") format("embedded-opentype"), |
| 249 |
url("' . WPSSO_URLPATH . 'fonts/icons.woff?' . $this->version . '") format("woff"), |
| 250 |
url("' . WPSSO_URLPATH . 'fonts/icons.ttf?' . $this->version . '") format("truetype"), |
| 251 |
url("' . WPSSO_URLPATH . 'fonts/icons.svg?' . $this->version . '#icons") format("svg"); |
| 252 |
} |
| 253 |
@font-face { |
| 254 |
font-family:"WpssoStar"; |
| 255 |
font-weight:normal; |
| 256 |
font-style:normal; |
| 257 |
src:url("' . WPSSO_URLPATH . 'fonts/star.eot?' . $this->version . '"); |
| 258 |
src:url("' . WPSSO_URLPATH . 'fonts/star.eot?' . $this->version . '#iefix") format("embedded-opentype"), |
| 259 |
url("' . WPSSO_URLPATH . 'fonts/star.woff?' . $this->version . '") format("woff"), |
| 260 |
url("' . WPSSO_URLPATH . 'fonts/star.ttf?' . $this->version . '") format("truetype"), |
| 261 |
url("' . WPSSO_URLPATH . 'fonts/star.svg?' . $this->version . '#star") format("svg"); |
| 262 |
} |
| 263 |
'; |
| 264 |
|
| 265 |
/* |
| 266 |
* Admin menu and sub-menu items. |
| 267 |
*/ |
| 268 |
if ( $menu_pagehook ) { // Just in case. |
| 269 |
|
| 270 |
$custom_style_css .= ' |
| 271 |
#adminmenu #' . $menu_pagehook . ' div.wp-menu-name { /* Prevent excessive word breaks in French. */ |
| 272 |
word-break:initial; |
| 273 |
word-wrap:initial; |
| 274 |
hyphens:initial; |
| 275 |
} |
| 276 |
#adminmenu li.menu-top.' . $menu_pagehook . ' div.wp-menu-image::before, |
| 277 |
#adminmenu li.menu-top.' . $menu_pagehook . ':hover div.wp-menu-image::before { |
| 278 |
content:"' . $this->p->cf[ 'menu' ][ 'icon-code' ] . '"; |
| 279 |
font-family:'. $this->p->cf[ 'menu' ][ 'icon-font' ] . '; |
| 280 |
} |
| 281 |
#adminmenu ul.wp-submenu div.wpsso-menu-item.top-last-submenu-page.with-add-ons { |
| 282 |
padding-bottom:12px; |
| 283 |
border-bottom:1px solid; |
| 284 |
} |
| 285 |
'; |
| 286 |
} |
| 287 |
|
| 288 |
/* |
| 289 |
* Settings pages. |
| 290 |
*/ |
| 291 |
$custom_style_css .= ' |
| 292 |
#profile-page.wrap #your-profile #wpsso_' . $metabox_id . '.postbox h3:first-of-type { |
| 293 |
margin:0; |
| 294 |
} |
| 295 |
#wpsso_' . $metabox_id . '.postbox { |
| 296 |
min-width:455px; /* The default WordPress postbox minimum width is 255px. */ |
| 297 |
} |
| 298 |
#wpsso_' . $metabox_id . ' .inside { |
| 299 |
padding:0; |
| 300 |
margin:0; |
| 301 |
} |
| 302 |
'; |
| 303 |
|
| 304 |
/* |
| 305 |
* List table columns. |
| 306 |
*/ |
| 307 |
foreach ( array( |
| 308 |
'.column-title' => 'width:30%; max-width:15vw;', |
| 309 |
'.column-name' => 'width:30%; max-width:15vw;', |
| 310 |
'' => 'width:15%; max-width:15vw;', |
| 311 |
) as $css_class => $width_css ) { |
| 312 |
|
| 313 |
/* |
| 314 |
* WooCommerce changes their tabs to icons at 900px. |
| 315 |
* WordPress collapses the admin menu at 960px. |
| 316 |
* WordPress changes to larger icons at 782px. |
| 317 |
* |
| 318 |
* WPSSO uses @media max-width values of 1330px, 1200px, 960px, 782px, and 600px. |
| 319 |
*/ |
| 320 |
$custom_style_css .= "\n@media screen and ( min-width:782px ) {\n"; // Open code block. |
| 321 |
|
| 322 |
switch ( $css_class ) { |
| 323 |
|
| 324 |
case '': // Only apply to posts and pages. |
| 325 |
|
| 326 |
$custom_style_css .= "\ttable.wp-list-table.posts > thead > tr > th,\n"; |
| 327 |
$custom_style_css .= "\ttable.wp-list-table.posts > tbody > tr > td,\n"; |
| 328 |
$custom_style_css .= "\ttable.wp-list-table.pages > thead > tr > th,\n"; |
| 329 |
$custom_style_css .= "\ttable.wp-list-table.pages > tbody > tr > td {\n"; // Open code block. |
| 330 |
|
| 331 |
break; |
| 332 |
|
| 333 |
default: // Apply to every WP List Table. |
| 334 |
|
| 335 |
$custom_style_css .= "\t" . 'table.wp-list-table.posts > thead > tr > th' . $css_class . ",\n"; |
| 336 |
$custom_style_css .= "\t" . 'table.wp-list-table.posts > tbody > tr > td' . $css_class . ",\n"; |
| 337 |
$custom_style_css .= "\t" . 'table.wp-list-table.pages > thead > tr > th' . $css_class . ",\n"; |
| 338 |
$custom_style_css .= "\t" . 'table.wp-list-table.pages > tbody > tr > td' . $css_class . ",\n"; |
| 339 |
$custom_style_css .= "\t" . 'table.wp-list-table > thead > tr > th' . $css_class . ",\n"; |
| 340 |
$custom_style_css .= "\t" . 'table.wp-list-table > tbody > tr > td' . $css_class . " {\n"; // Open code block. |
| 341 |
|
| 342 |
break; |
| 343 |
} |
| 344 |
|
| 345 |
$custom_style_css .= "\t\t" . $width_css . "\n"; |
| 346 |
$custom_style_css .= "\t}\n"; // Close code block. |
| 347 |
$custom_style_css .= "}\n"; // Close code block. |
| 348 |
} |
| 349 |
|
| 350 |
$custom_style_css .= ' |
| 351 |
table.wp-list-table > thead > tr > td#cb, /* Note thead with td. */ |
| 352 |
table.wp-list-table > thead > tr > td.column-cb, /* Note thead with td. */ |
| 353 |
table.wp-list-table > tbody > tr > th.column-cb, /* Note tbody with th. */ |
| 354 |
table.wp-list-table > thead > tr > td.check-column, /* Note thead with td. */ |
| 355 |
table.wp-list-table > tbody > tr > th.check-column { /* Note tbody with th. */ |
| 356 |
width:2.2em; |
| 357 |
} |
| 358 |
table.wp-list-table > thead > tr > th.column-author, |
| 359 |
table.wp-list-table > tbody > tr > td.column-author { |
| 360 |
width:15%; |
| 361 |
} |
| 362 |
table.wp-list-table > thead > tr > th.column-categories, |
| 363 |
table.wp-list-table > tbody > tr > td.column-categories, |
| 364 |
table.wp-list-table > thead > tr > th.column-product_cat, |
| 365 |
table.wp-list-table > tbody > tr > td.column-product_cat { |
| 366 |
width:20%; |
| 367 |
} |
| 368 |
table.wp-list-table > thead > tr > th.column-tags, |
| 369 |
table.wp-list-table > tbody > tr > td.column-tags, |
| 370 |
table.wp-list-table > thead > tr > th.column-taxonomy-page_tag, |
| 371 |
table.wp-list-table > tbody > tr > td.column-taxonomy-page_tag, |
| 372 |
table.wp-list-table > thead > tr > th.column-product_tag, |
| 373 |
table.wp-list-table > tbody > tr > td.column-product_tag { |
| 374 |
width:15%; |
| 375 |
} |
| 376 |
table.wp-list-table > thead > tr > th.column-description, |
| 377 |
table.wp-list-table > tbody > tr > td.column-description { |
| 378 |
width:20%; |
| 379 |
} |
| 380 |
table.wp-list-table.plugins > thead > tr > th.column-description, |
| 381 |
table.wp-list-table.plugins > tbody > tr > td.column-description { /* Plugins table. */ |
| 382 |
width:75%; |
| 383 |
} |
| 384 |
table.wp-list-table.tags > thead > tr > th.column-description, |
| 385 |
table.wp-list-table.tags > tbody > tr > td.column-description { /* Taxonomy table */ |
| 386 |
width:25%; |
| 387 |
} |
| 388 |
table.wp-list-table.users > thead > tr > th, |
| 389 |
table.wp-list-table.users > tbody > tr > td { /* Users table. */ |
| 390 |
width:15%; |
| 391 |
} |
| 392 |
table.wp-list-table.users > thead > tr > th.column-email, |
| 393 |
table.wp-list-table.users > tbody > tr > td.column-email { |
| 394 |
width:20%; |
| 395 |
} |
| 396 |
table.wp-list-table > thead > tr > th.num, |
| 397 |
table.wp-list-table > tbody > tr > td.num, |
| 398 |
table.wp-list-table > thead > tr > th.column-comments, |
| 399 |
table.wp-list-table > tbody > tr > td.column-comments { |
| 400 |
width:50px; |
| 401 |
} |
| 402 |
table.wp-list-table > thead > tr > th.column-posts.num, |
| 403 |
table.wp-list-table > tbody > tr > td.column-posts.num { /* Counter. */ |
| 404 |
width:80px; |
| 405 |
} |
| 406 |
table.wp-list-table > thead > tr > th.column-featured, |
| 407 |
table.wp-list-table > tbody > tr > td.column-featured { |
| 408 |
width:20px; |
| 409 |
} |
| 410 |
table.wp-list-table > thead > tr > th.column-sku, |
| 411 |
table.wp-list-table > tbody > tr > td.column-sku, |
| 412 |
table.wp-list-table > thead > tr > th.column-wpm_pgw_code, |
| 413 |
table.wp-list-table > tbody > tr > td.column-wpm_pgw_code { |
| 414 |
width:80px; |
| 415 |
} |
| 416 |
table.wp-list-table > thead > tr > th.column-date, |
| 417 |
table.wp-list-table > tbody > tr > td.column-date, |
| 418 |
table.wp-list-table > thead > tr > th.column-expirationdate, |
| 419 |
table.wp-list-table > tbody > tr > td.column-expirationdate { |
| 420 |
width:8em; |
| 421 |
} |
| 422 |
table.wp-list-table > thead > tr > th.column-job_position, |
| 423 |
table.wp-list-table > tbody > tr > td.column-job_position { /* WP Job Manager. */ |
| 424 |
width:20%; |
| 425 |
} |
| 426 |
table.wp-list-table > thead > tr > th.column-job_listing_type, |
| 427 |
table.wp-list-table > tbody > tr > td.column-job_listing_type { |
| 428 |
width:5em; |
| 429 |
} |
| 430 |
table.wp-list-table > thead > tr > th.column-job_location, |
| 431 |
table.wp-list-table > tbody > tr > td.column-job_location { |
| 432 |
width:10em; |
| 433 |
} |
| 434 |
table.wp-list-table > thead > tr > th.column-job_status, |
| 435 |
table.wp-list-table > tbody > tr > td.column-job_status, |
| 436 |
table.wp-list-table > thead > tr > th.column-featured_job, |
| 437 |
table.wp-list-table > tbody > tr > td.column-featured_job, |
| 438 |
table.wp-list-table > thead > tr > th.column-filled, |
| 439 |
table.wp-list-table > tbody > tr > td.column-filled { |
| 440 |
width:1em; |
| 441 |
} |
| 442 |
table.wp-list-table > thead > tr > th.column-job_posted, |
| 443 |
table.wp-list-table > tbody > tr > td.column-job_posted, |
| 444 |
table.wp-list-table > thead > tr > th.column-job_expires, |
| 445 |
table.wp-list-table > tbody > tr > td.column-job_expires { |
| 446 |
width:7em; |
| 447 |
} |
| 448 |
table.wp-list-table > thead > tr > th.column-job_actions, |
| 449 |
table.wp-list-table > tbody > tr > td.column-job_actions { |
| 450 |
width:7em; |
| 451 |
} |
| 452 |
table.wp-list-table > thead > tr > th.column-seotitle, |
| 453 |
table.wp-list-table > tbody > tr > td.column-seotitle, |
| 454 |
table.wp-list-table > thead > tr > th.column-seodesc, |
| 455 |
table.wp-list-table > tbody > tr > td.column-seodesc { /* All in One SEO. */ |
| 456 |
width:20%; |
| 457 |
} |
| 458 |
table.wp-list-table > thead > tr > th.column-shortcode, |
| 459 |
table.wp-list-table > tbody > tr > td.column-shortcode { |
| 460 |
width:25%; |
| 461 |
} |
| 462 |
table.wp-list-table > thead > tr > th.column-term-id, |
| 463 |
table.wp-list-table > tbody > tr > td.column-term-id { |
| 464 |
width:40px; |
| 465 |
} |
| 466 |
table.wp-list-table > thead > tr > th.column-thumb, |
| 467 |
table.wp-list-table > tbody > tr > td.column-thumb { /* WooCommerce Brands */ |
| 468 |
width:60px; |
| 469 |
} |
| 470 |
table.wp-list-table > thead > tr > th.column-template, |
| 471 |
table.wp-list-table > tbody > tr > td.column-template { |
| 472 |
width:10%; |
| 473 |
} |
| 474 |
table.wp-list-table > thead > tr > th.column-wr2x_column, |
| 475 |
table.wp-list-table > tbody > tr > td.column-wr2x_column { /* Perfect Images */ |
| 476 |
width:20%; |
| 477 |
} |
| 478 |
table.wp-list-table > tbody > tr > td.column-wpsso_schema_type, |
| 479 |
table.wp-list-table > tbody > tr > td.column-wpsso_og_type, |
| 480 |
table.wp-list-table > tbody > tr > td.column-wpsso_og_desc { |
| 481 |
direction:ltr; |
| 482 |
font-family:"Helvetica"; |
| 483 |
text-align:left; |
| 484 |
word-wrap:break-word; |
| 485 |
} |
| 486 |
table.wp-list-table > tbody > tr > td.column-wpsso_og_desc { |
| 487 |
overflow:hidden; |
| 488 |
} |
| 489 |
@media screen and ( max-width:1330px ) { |
| 490 |
|
| 491 |
th.column-wpsso_og_desc, |
| 492 |
td.column-wpsso_og_desc { |
| 493 |
display:none; |
| 494 |
} |
| 495 |
} |
| 496 |
'; |
| 497 |
|
| 498 |
foreach ( $sortable_cols as $col_name => $col_info ) { |
| 499 |
|
| 500 |
if ( isset( $col_info[ 'width' ] ) ) { |
| 501 |
|
| 502 |
$custom_style_css .= ' |
| 503 |
table.wp-list-table > thead > tr > th.column-wpsso_' . $col_name . ', |
| 504 |
table.wp-list-table > tbody > tr > td.column-wpsso_' . $col_name . ' { |
| 505 |
width:' . $col_info[ 'width' ] . ' !important; |
| 506 |
min-width:' . $col_info[ 'width' ] . ' !important; |
| 507 |
} |
| 508 |
'; |
| 509 |
} |
| 510 |
} |
| 511 |
|
| 512 |
if ( isset( $sortable_cols[ 'og_img' ][ 'width' ] ) ) { // Just in case. |
| 513 |
|
| 514 |
$custom_style_css .= ' |
| 515 |
table.wp-list-table > thead > tr > th.column-wpsso_og_img, |
| 516 |
table.wp-list-table > tbody > tr > td.column-wpsso_og_img { |
| 517 |
max-width:' . $sortable_cols[ 'og_img' ][ 'width' ] . ' !important; |
| 518 |
} |
| 519 |
'; |
| 520 |
|
| 521 |
if ( isset( $sortable_cols[ 'og_img' ][ 'height' ] ) ) { // Just in case. |
| 522 |
|
| 523 |
$custom_style_css .= ' |
| 524 |
table.wp-list-table > tbody > tr > td.column-wpsso_og_img div.wp-thumb-bg-img { |
| 525 |
max-width:' . $sortable_cols[ 'og_img' ][ 'width' ] . ' !important; |
| 526 |
height:' . $sortable_cols[ 'og_img' ][ 'height' ] . '; |
| 527 |
min-height:' . $sortable_cols[ 'og_img' ][ 'height' ] . '; |
| 528 |
background-size:' . $sortable_cols[ 'og_img' ][ 'width' ] . ' auto; |
| 529 |
background-repeat:no-repeat; |
| 530 |
background-position:center center; |
| 531 |
overflow:hidden; |
| 532 |
margin:0; |
| 533 |
padding:0; |
| 534 |
} |
| 535 |
'; |
| 536 |
} |
| 537 |
} |
| 538 |
|
| 539 |
$custom_style_css = apply_filters( $filter_name, $custom_style_css ); |
| 540 |
|
| 541 |
if ( $this->p->debug->enabled ) { |
| 542 |
|
| 543 |
$this->p->debug->log( 'saving sucom-admin-page inline style to cache' ); |
| 544 |
} |
| 545 |
|
| 546 |
if ( ! $this->doing_dev ) { |
| 547 |
|
| 548 |
$custom_style_css = SucomUtil::minify_css( $custom_style_css, $filter_prefix = 'wpsso' ); |
| 549 |
|
| 550 |
set_transient( $cache_id, $custom_style_css, $cache_exp_secs ); |
| 551 |
} |
| 552 |
|
| 553 |
if ( $this->p->debug->enabled ) { |
| 554 |
|
| 555 |
$this->p->debug->log( 'adding sucom-admin-page inline style' ); |
| 556 |
} |
| 557 |
|
| 558 |
wp_add_inline_style( 'sucom-admin-page', $custom_style_css ); |
| 559 |
|
| 560 |
if ( $this->p->debug->enabled ) { |
| 561 |
|
| 562 |
$this->p->debug->mark( 'create and minify admin page style' ); // End timer. |
| 563 |
} |
| 564 |
} |
| 565 |
|
| 566 |
/* |
| 567 |
* This method is run a second time by the 'admin_enqueue_scripts' action with a priority of PHP_INT_MAX to make |
| 568 |
* sure another plugin (like Squirrly SEO) has not cleared our admin page styles from the queue. |
| 569 |
*/ |
| 570 |
public function admin_enqueue_page_styles( $hook_name ) { |
| 571 |
|
| 572 |
$style_handles = array( 'sucom-admin-page' ); |
| 573 |
|
| 574 |
static $is_enqueued = null; // Default value for first execution. |
| 575 |
|
| 576 |
if ( ! $is_enqueued ) { // Re-check the $wp_styles queue at priority PHP_INT_MAX. |
| 577 |
|
| 578 |
add_action( 'admin_enqueue_scripts', array( $this, __FUNCTION__ ), PHP_INT_MAX ); |
| 579 |
} |
| 580 |
|
| 581 |
global $wp_styles; |
| 582 |
|
| 583 |
foreach ( $style_handles as $handle ) { |
| 584 |
|
| 585 |
if ( ! $is_enqueued || ! isset( $wp_styles->queue ) || ! in_array( $handle, $wp_styles->queue ) ) { |
| 586 |
|
| 587 |
if ( $this->p->debug->enabled ) { |
| 588 |
|
| 589 |
$this->p->debug->log( 'enqueueing style ' . $handle ); |
| 590 |
} |
| 591 |
|
| 592 |
wp_enqueue_style( $handle ); |
| 593 |
|
| 594 |
} elseif ( $this->p->debug->enabled ) { |
| 595 |
|
| 596 |
$this->p->debug->log( $handle . ' style already enqueued' ); |
| 597 |
} |
| 598 |
} |
| 599 |
|
| 600 |
$is_enqueued = true; // Signal that we've already run once. |
| 601 |
} |
| 602 |
|
| 603 |
private function plugin_install_inline_style( $hook_name, $plugin_slug = false ) { // $hook_name = plugin-install.php |
| 604 |
|
| 605 |
if ( $this->p->debug->enabled ) { |
| 606 |
|
| 607 |
$this->p->debug->mark(); |
| 608 |
} |
| 609 |
|
| 610 |
/* |
| 611 |
* Fix the WordPress banner resolution. |
| 612 |
*/ |
| 613 |
if ( false !== $plugin_slug && ! empty( $this->p->cf[ '*' ][ 'slug' ][ $plugin_slug ] ) ) { |
| 614 |
|
| 615 |
$ext = $this->p->cf[ '*' ][ 'slug' ][ $plugin_slug ]; |
| 616 |
|
| 617 |
if ( ! empty( $this->p->cf[ 'plugin' ][ $ext ][ 'assets' ][ 'banners' ] ) ) { |
| 618 |
|
| 619 |
$banners = $this->p->cf[ 'plugin' ][ $ext ][ 'assets' ][ 'banners' ]; |
| 620 |
|
| 621 |
echo '<style type="text/css">' . "\n"; |
| 622 |
|
| 623 |
/* |
| 624 |
* Banner image array keys are 'low' and 'high'. |
| 625 |
*/ |
| 626 |
if ( ! empty( $banners[ 'low' ] ) ) { |
| 627 |
|
| 628 |
echo '#plugin-information #plugin-information-title.with-banner { '. |
| 629 |
'background-image: url( ' . esc_url( $banners[ 'low' ] ) . ' ); }' . "\n"; |
| 630 |
} |
| 631 |
|
| 632 |
if ( ! empty( $banners[ 'high' ] ) ) { |
| 633 |
|
| 634 |
echo '@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) { ' . |
| 635 |
'#plugin-information #plugin-information-title.with-banner { ' . |
| 636 |
'background-image: url( ' . esc_url( $banners[ 'high' ] ) . ' ); } }' . "\n"; |
| 637 |
} |
| 638 |
|
| 639 |
echo '</style>' . "\n"; |
| 640 |
} |
| 641 |
} |
| 642 |
|
| 643 |
echo ' |
| 644 |
<style type="text/css"> |
| 645 |
|
| 646 |
/* |
| 647 |
* Hide the plugin name overlay. |
| 648 |
*/ |
| 649 |
body#plugin-information div#plugin-information-title.with-banner h2 { |
| 650 |
display:none; |
| 651 |
} |
| 652 |
|
| 653 |
body#plugin-information div#plugin-information-content div#section-holder.wrap { |
| 654 |
clear:none; |
| 655 |
} |
| 656 |
|
| 657 |
body#plugin-information.rtl .section { |
| 658 |
direction:rtl; |
| 659 |
} |
| 660 |
|
| 661 |
body#plugin-information #section-description img { |
| 662 |
max-width:100%; |
| 663 |
} |
| 664 |
|
| 665 |
body#plugin-information #section-description img.readme-icon { |
| 666 |
float:left; |
| 667 |
width:30%; |
| 668 |
min-width:128px; |
| 669 |
max-width:256px; |
| 670 |
margin:0 30px 15px 0; |
| 671 |
} |
| 672 |
|
| 673 |
body#plugin-information #section-description img.readme-example { |
| 674 |
width:100%; |
| 675 |
min-width:256px; |
| 676 |
max-width:600px; |
| 677 |
margin:30px 0 30px 0; |
| 678 |
} |
| 679 |
|
| 680 |
body#plugin-information #section-other_notes h3 { |
| 681 |
clear:none; |
| 682 |
display:none; |
| 683 |
} |
| 684 |
|
| 685 |
</style> |
| 686 |
'; |
| 687 |
} |
| 688 |
} |
| 689 |
} |
| 690 |
|