| 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 ( ! class_exists( 'WpssoSubmenuAddons' ) && class_exists( 'WpssoAdmin' ) ) { |
| 14 |
|
| 15 |
/* |
| 16 |
* This settings page requires enqueuing special scripts and styles for the plugin details / install thickbox link. |
| 17 |
* |
| 18 |
* See the WpssoScript and WpssoStyle classes for more info. |
| 19 |
*/ |
| 20 |
class WpssoSubmenuAddons extends WpssoAdmin { |
| 21 |
|
| 22 |
public function __construct( &$plugin, $id, $name, $lib, $ext ) { |
| 23 |
|
| 24 |
$this->p =& $plugin; |
| 25 |
|
| 26 |
if ( $this->p->debug->enabled ) { |
| 27 |
|
| 28 |
$this->p->debug->mark(); |
| 29 |
} |
| 30 |
|
| 31 |
$this->menu_id = $id; |
| 32 |
$this->menu_name = $name; |
| 33 |
$this->menu_lib = $lib; |
| 34 |
$this->menu_ext = $ext; |
| 35 |
|
| 36 |
$this->menu_metaboxes = array( |
| 37 |
'addons' => _x( 'Free Plugin Add-ons', 'metabox title', 'wpsso' ), |
| 38 |
); |
| 39 |
} |
| 40 |
|
| 41 |
/* |
| 42 |
* Remove all action buttons. |
| 43 |
*/ |
| 44 |
protected function add_form_buttons( &$form_button_rows ) { |
| 45 |
|
| 46 |
$form_button_rows = array(); |
| 47 |
} |
| 48 |
|
| 49 |
/* |
| 50 |
* Callback method must be public for add_meta_box() hook. |
| 51 |
* |
| 52 |
* See WpssoAdmin->add_settings_page_metaboxes(). |
| 53 |
*/ |
| 54 |
public function show_metabox_addons( $obj, $mb ) { |
| 55 |
|
| 56 |
if ( $this->p->debug->enabled ) { |
| 57 |
|
| 58 |
$this->p->debug->mark(); |
| 59 |
} |
| 60 |
|
| 61 |
$ext_sorted = WpssoConfig::get_ext_sorted(); |
| 62 |
|
| 63 |
unset( $ext_sorted[ $this->p->id ] ); |
| 64 |
|
| 65 |
$tabindex = 0; |
| 66 |
$ext_num = 0; |
| 67 |
$ext_total = count( $ext_sorted ); |
| 68 |
$pkg_info = $this->p->util->get_pkg_info(); // Uses a local cache. |
| 69 |
$charset = get_bloginfo( $show = 'charset', $filter = 'raw' ); |
| 70 |
$icon_px = 100; |
| 71 |
|
| 72 |
echo '<table class="sucom-settings wpsso addons-metabox" style="padding-bottom:10px">' . "\n"; |
| 73 |
|
| 74 |
foreach ( $ext_sorted as $ext => $info ) { |
| 75 |
|
| 76 |
if ( empty( $info[ 'name' ] ) ) { |
| 77 |
|
| 78 |
continue; |
| 79 |
} |
| 80 |
|
| 81 |
$ext_num++; |
| 82 |
|
| 83 |
$ext_links = $this->get_ext_action_links( $ext, $info, $tabindex ); |
| 84 |
$ext_name_html = '<h4>' . |
| 85 |
htmlentities( $pkg_info[ $ext ][ 'name' ], ENT_QUOTES, $charset, $double_encode = false ) . ' (' . |
| 86 |
htmlentities( $pkg_info[ $ext ][ 'short' ], ENT_QUOTES, $charset, $double_encode = false ) . ')' . |
| 87 |
'</h4>'; |
| 88 |
$ext_desc_transl = _x( $info[ 'desc' ], 'plugin description', 'wpsso' ); |
| 89 |
$ext_desc_html = '<p>' . htmlentities( $ext_desc_transl, ENT_QUOTES, $charset, $double_encode = false ) . '</p>'; |
| 90 |
|
| 91 |
$table_rows = array(); |
| 92 |
|
| 93 |
/* |
| 94 |
* Plugin name, description and links. |
| 95 |
*/ |
| 96 |
$table_rows[ 'plugin_name' ] = '<td class="ext-info-plugin-name" id="ext-info-plugin-name-' . $ext . '">' . |
| 97 |
'<a class="ext-anchor" id="' . $ext . '"></a>' . $ext_name_html . $ext_desc_html . |
| 98 |
( empty( $ext_links ) ? '' : '<div class="row-actions visible">' . implode( $glue = ' | ', $ext_links ) . '</div>' ) . |
| 99 |
'</td>'; |
| 100 |
|
| 101 |
/* |
| 102 |
* Plugin separator. |
| 103 |
*/ |
| 104 |
if ( $ext_num < $ext_total ) { |
| 105 |
|
| 106 |
$table_rows[ 'dotted_line' ] = '<td class="ext-info-plugin-separator"></td>'; |
| 107 |
|
| 108 |
} else { |
| 109 |
|
| 110 |
$table_rows[] = '<td></td>'; |
| 111 |
} |
| 112 |
|
| 113 |
/* |
| 114 |
* Show the plugin icon and table rows. |
| 115 |
*/ |
| 116 |
foreach ( $table_rows as $key => $row ) { |
| 117 |
|
| 118 |
echo '<tr>'; |
| 119 |
|
| 120 |
if ( $key === 'plugin_name' ) { |
| 121 |
|
| 122 |
$span_rows = count( $table_rows ); |
| 123 |
$icon_col_px = $icon_px + 30; |
| 124 |
$icon_style = 'width:' . $icon_col_px . 'px; min-width:' . $icon_col_px . 'px; max-width:' . $icon_col_px . 'px;'; |
| 125 |
|
| 126 |
echo '<td class="ext-info-plugin-icon" id="ext-info-plugin-icon-' . $ext . '" ' . |
| 127 |
'rowspan="' . $span_rows . '" style="' . $icon_style . '" >'; |
| 128 |
echo $this->get_ext_img_icon( $ext, $icon_px ); |
| 129 |
echo '</td>'; |
| 130 |
} |
| 131 |
|
| 132 |
echo $row . '</tr>' . "\n"; |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
echo '</table>' . "\n"; |
| 137 |
} |
| 138 |
} |
| 139 |
} |
| 140 |
|