stupid PHP 4
This commit is contained in:
parent
8a4e7f9877
commit
35b9bf71e8
@ -33,13 +33,32 @@ class PluginWonderful {
|
|||||||
|
|
||||||
$this->_get_publisher_info();
|
$this->_get_publisher_info();
|
||||||
$this->_update_database_version();
|
$this->_update_database_version();
|
||||||
|
$this->_update_plugin_wonderful();
|
||||||
if ($wp_version < 2.8) {
|
|
||||||
register_sidebar_widget(__('Plugin Wonderful', 'plugin-wonderful'), array($this, 'render_pre28_widget'));
|
|
||||||
register_widget_control(__('Plugin Wonderful', 'plugin-wonderful'), array($this, 'render_pre28_widget_control'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($_POST)) { $this->handle_action(); }
|
if (!empty($_POST)) { $this->handle_action(); }
|
||||||
|
$this->_update_plugin_wonderful();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fix PHP 4's full-of-fail object handling.
|
||||||
|
*/
|
||||||
|
function _update_plugin_wonderful() {
|
||||||
|
if (version_compare("5", phpversion(), ">")) {
|
||||||
|
global $plugin_wonderful;
|
||||||
|
$plugin_wonderful = $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fix PHP 4's full-of-fail object handling.
|
||||||
|
*/
|
||||||
|
function _update_this() {
|
||||||
|
if (version_compare("5", phpversion(), ">")) {
|
||||||
|
global $plugin_wonderful;
|
||||||
|
foreach ((array)$plugin_wonderful as $field => $value) {
|
||||||
|
$this->{$field} = $plugin_wonderful->{$field};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +90,7 @@ class PluginWonderful {
|
|||||||
function _get_publisher_info() {
|
function _get_publisher_info() {
|
||||||
$this->publisher_info = false;
|
$this->publisher_info = false;
|
||||||
$member_id = get_option('plugin-wonderful-memberid');
|
$member_id = get_option('plugin-wonderful-memberid');
|
||||||
|
|
||||||
if (is_numeric($member_id)) {
|
if (is_numeric($member_id)) {
|
||||||
$member_id = (int)$member_id;
|
$member_id = (int)$member_id;
|
||||||
$this->publisher_info = $this->adboxes_client->get_ads($member_id);
|
$this->publisher_info = $this->adboxes_client->get_ads($member_id);
|
||||||
@ -88,6 +108,7 @@ class PluginWonderful {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function insert_rss_feed_ads($content) {
|
function insert_rss_feed_ads($content) {
|
||||||
|
$this->_update_this();
|
||||||
if (is_feed()) {
|
if (is_feed()) {
|
||||||
if ($this->publisher_info !== false) {
|
if ($this->publisher_info !== false) {
|
||||||
foreach ($this->publisher_info->adboxes as $adbox) {
|
foreach ($this->publisher_info->adboxes as $adbox) {
|
||||||
@ -109,6 +130,7 @@ class PluginWonderful {
|
|||||||
* @return string The modified body.
|
* @return string The modified body.
|
||||||
*/
|
*/
|
||||||
function inject_ads_into_body_copy($body) {
|
function inject_ads_into_body_copy($body) {
|
||||||
|
$this->_update_this();
|
||||||
if ($this->publisher_info !== false) {
|
if ($this->publisher_info !== false) {
|
||||||
if (get_option("plugin-wonderful-enable-body-copy-embedding") == 1) {
|
if (get_option("plugin-wonderful-enable-body-copy-embedding") == 1) {
|
||||||
return $this->publisher_info->inject_ads_into_body_copy($body, (get_option("plugin-wonderful-use-standardcode") == 1));
|
return $this->publisher_info->inject_ads_into_body_copy($body, (get_option("plugin-wonderful-use-standardcode") == 1));
|
||||||
@ -127,6 +149,7 @@ class PluginWonderful {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function plugin_wonderful_main() {
|
function plugin_wonderful_main() {
|
||||||
|
$this->_update_this();
|
||||||
$this->show_view(new PluginWonderfulViewMain());
|
$this->show_view(new PluginWonderfulViewMain());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +189,7 @@ class PluginWonderful {
|
|||||||
if (!empty($_POST['_pw_nonce'])) {
|
if (!empty($_POST['_pw_nonce'])) {
|
||||||
if (wp_verify_nonce($_POST['_pw_nonce'], 'plugin-wonderful')) {
|
if (wp_verify_nonce($_POST['_pw_nonce'], 'plugin-wonderful')) {
|
||||||
$action = "handle_action_" . str_replace("-", "_", preg_replace('#[^a-z0-9\-]#', '', strtolower($_POST['_pw_action'])));
|
$action = "handle_action_" . str_replace("-", "_", preg_replace('#[^a-z0-9\-]#', '', strtolower($_POST['_pw_action'])));
|
||||||
if (method_exists($this, $action)) { call_user_func(array($this, $action)); }
|
if (method_exists($this, $action)) { $this->{$action}(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,10 +253,12 @@ class PluginWonderful {
|
|||||||
if (count($this->messages) == 0) {
|
if (count($this->messages) == 0) {
|
||||||
$this->messages[] = __("No changes to adboxes were made.", 'plugin-wonderful');
|
$this->messages[] = __("No changes to adboxes were made.", 'plugin-wonderful');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $changes;
|
return $changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _download_project_wonderful_data($member_id) {
|
function _download_project_wonderful_data($member_id) {
|
||||||
|
global $plugin_wonderful;
|
||||||
if (($result = $this->_retrieve_url(sprintf(PLUGIN_WONDERFUL_XML_URL, $member_id))) !== false) {
|
if (($result = $this->_retrieve_url(sprintf(PLUGIN_WONDERFUL_XML_URL, $member_id))) !== false) {
|
||||||
$this->publisher_info = $this->_get_new_publisher_info_object();
|
$this->publisher_info = $this->_get_new_publisher_info_object();
|
||||||
if ($this->publisher_info->parse($result)) {
|
if ($this->publisher_info->parse($result)) {
|
||||||
@ -358,6 +383,7 @@ class PluginWonderful {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function render_pre28_widget() {
|
function render_pre28_widget() {
|
||||||
|
$this->_update_this();
|
||||||
$data = get_option('plugin-wonderful-pre28-widget-info');
|
$data = get_option('plugin-wonderful-pre28-widget-info');
|
||||||
if (is_array($data)) {
|
if (is_array($data)) {
|
||||||
if (count(array_intersect(array_keys($data), array("adboxid", "center"))) == 2) {
|
if (count(array_intersect(array_keys($data), array("adboxid", "center"))) == 2) {
|
||||||
@ -396,6 +422,7 @@ class PluginWonderful {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function render_pre28_widget_control() {
|
function render_pre28_widget_control() {
|
||||||
|
$this->_update_this();
|
||||||
$instance = $this->_normalize_pre28_option();
|
$instance = $this->_normalize_pre28_option();
|
||||||
|
|
||||||
echo '<input type="hidden" name="_pw_nonce" value="' . wp_create_nonce('plugin-wonderful') . '" />';
|
echo '<input type="hidden" name="_pw_nonce" value="' . wp_create_nonce('plugin-wonderful') . '" />';
|
||||||
|
@ -43,8 +43,11 @@ add_action('admin_menu', array($plugin_wonderful, 'set_up_menu'));
|
|||||||
add_action('init', array($plugin_wonderful, 'init'));
|
add_action('init', array($plugin_wonderful, 'init'));
|
||||||
add_filter('the_excerpt_rss', array($plugin_wonderful, 'insert_rss_feed_ads'));
|
add_filter('the_excerpt_rss', array($plugin_wonderful, 'insert_rss_feed_ads'));
|
||||||
add_filter('the_content', array($plugin_wonderful, 'inject_ads_into_body_copy'));
|
add_filter('the_content', array($plugin_wonderful, 'inject_ads_into_body_copy'));
|
||||||
if ($wp_version >= 2.8) {
|
if (version_compare($wp_version, "2.8", ">=")) {
|
||||||
add_action('widgets_init', '__plugin_wonderful_load_widgets');
|
add_action('widgets_init', '__plugin_wonderful_load_widgets');
|
||||||
|
} else {
|
||||||
|
register_sidebar_widget(__('Plugin Wonderful', 'plugin-wonderful'), array($this, 'render_pre28_widget'));
|
||||||
|
register_widget_control(__('Plugin Wonderful', 'plugin-wonderful'), array($this, 'render_pre28_widget_control'));
|
||||||
}
|
}
|
||||||
|
|
||||||
register_activation_hook(__FILE__, array($plugin_wonderful, 'handle_activation'));
|
register_activation_hook(__FILE__, array($plugin_wonderful, 'handle_activation'));
|
||||||
|
@ -17,7 +17,7 @@ class PluginWonderfulViewMain {
|
|||||||
global $plugin_wonderful;
|
global $plugin_wonderful;
|
||||||
|
|
||||||
$this->first_adboxid = null;
|
$this->first_adboxid = null;
|
||||||
if ($plugin_wonderful->publisher_info !== false) {
|
if (!empty($plugin_wonderful->publisher_info)) {
|
||||||
foreach ($plugin_wonderful->publisher_info->adboxes as $adbox) {
|
foreach ($plugin_wonderful->publisher_info->adboxes as $adbox) {
|
||||||
if (empty($this->first_adboxid)) {
|
if (empty($this->first_adboxid)) {
|
||||||
if (!empty($adbox->template_tag_id)) {
|
if (!empty($adbox->template_tag_id)) {
|
||||||
@ -29,10 +29,11 @@ class PluginWonderfulViewMain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (is_null($this->first_adboxid)) { $this->first_adboxid = '12345'; }
|
||||||
}
|
}
|
||||||
|
|
||||||
function _partial_path($name) {
|
function _partial_path($name) {
|
||||||
return dirname(__FILE__) . '/' . __CLASS__ . '/' . $name . '.inc';
|
return dirname(__FILE__) . '/PluginWonderfulViewMain/' . $name . '.inc';
|
||||||
}
|
}
|
||||||
|
|
||||||
function _render_memberid_settings() {
|
function _render_memberid_settings() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php if (is_admin()) { ?>
|
<?php if (is_admin()) { ?>
|
||||||
<?php if ($plugin_wonderful->publisher_info !== false) { ?>
|
<?php if (!empty($plugin_wonderful->publisher_info)) { ?>
|
||||||
<h3><?php _e('Adbox Information', 'plugin-wonderful') ?></h3>
|
<h3><?php _e('Adbox Information', 'plugin-wonderful') ?></h3>
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
<input type="hidden" name="_pw_nonce" value="<?php echo $this->_pw_nonce ?>" />
|
<input type="hidden" name="_pw_nonce" value="<?php echo $this->_pw_nonce ?>" />
|
||||||
|
Loading…
Reference in New Issue
Block a user