Skip to content

Commit

Permalink
Fixes for PhP8 / v1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dernerd committed Oct 12, 2023
1 parent 02ccffa commit 7e8a988
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 33 deletions.
14 changes: 7 additions & 7 deletions custom-ads.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: PS BeitragsAds
Plugin URI: https://n3rds.work/cp_psource/ps-beitragsads-plugin/
Description: Definiere benutzerdefinierte Werbeanzeigen für Beitragstypen und mehr, das einfachste Werkzeug um effektiv Werbeanzeigen zu schalten.
Version: 1.5.9
Version: 1.6.0
Author: WMS N@W
Author URI: https://n3rds.work
Text Domain: wdca
Expand Down Expand Up @@ -37,19 +37,19 @@

//Setup proper paths/URLs and load text domains
if (is_multisite() && defined('WPMU_PLUGIN_URL') && defined('WPMU_PLUGIN_DIR') && file_exists(WPMU_PLUGIN_DIR . '/' . basename(__FILE__))) {
define ('WDCA_PLUGIN_LOCATION', 'mu-plugins', true);
define ('WDCA_PLUGIN_BASE_DIR', WPMU_PLUGIN_DIR, true);
define ('WDCA_PLUGIN_URL', str_replace('http://', WDCA_PROTOCOL, WPMU_PLUGIN_URL), true);
define ('WDCA_PLUGIN_LOCATION', 'mu-plugins');
define ('WDCA_PLUGIN_BASE_DIR', WPMU_PLUGIN_DIR);
define ('WDCA_PLUGIN_URL', str_replace('http://', WDCA_PROTOCOL, WPMU_PLUGIN_URL));
$textdomain_handler = 'load_muplugin_textdomain';
} else if (defined('WP_PLUGIN_URL') && defined('WP_PLUGIN_DIR') && file_exists(WP_PLUGIN_DIR . '/' . WDCA_PLUGIN_SELF_DIRNAME . '/' . basename(__FILE__))) {
define ('WDCA_PLUGIN_LOCATION', 'subfolder-plugins');
define ('WDCA_PLUGIN_BASE_DIR', WP_PLUGIN_DIR . '/' . WDCA_PLUGIN_SELF_DIRNAME);
define ('WDCA_PLUGIN_URL', str_replace('http://', WDCA_PROTOCOL, WP_PLUGIN_URL) . '/' . WDCA_PLUGIN_SELF_DIRNAME);
$textdomain_handler = 'load_plugin_textdomain';
} else if (defined('WP_PLUGIN_URL') && defined('WP_PLUGIN_DIR') && file_exists(WP_PLUGIN_DIR . '/' . basename(__FILE__))) {
define ('WDCA_PLUGIN_LOCATION', 'plugins', true);
define ('WDCA_PLUGIN_BASE_DIR', WP_PLUGIN_DIR, true);
define ('WDCA_PLUGIN_URL', str_replace('http://', WDCA_PROTOCOL, WP_PLUGIN_URL), true);
define ('WDCA_PLUGIN_LOCATION', 'plugins');
define ('WDCA_PLUGIN_BASE_DIR', WP_PLUGIN_DIR,);
define ('WDCA_PLUGIN_URL', str_replace('http://', WDCA_PROTOCOL, WP_PLUGIN_URL));
$textdomain_handler = 'load_plugin_textdomain';
} else {
// No textdomain is loaded because we can't determine the plugin location.
Expand Down
2 changes: 1 addition & 1 deletion js/wdca-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function wdca_openReelEditor() {
if (!mbuttons_container.length) return;

mbuttons_container.append('' +
'<a onclick="return wdca_openReelEditor();" title="' + l10nWdca.add_ad + '" class="thickbox" id="add_map" href="#TB_inline?width=640&height=594&inlineId=wdca_ad_container">' +
'<a onclick="return wdca_openReelEditor();" title="' + l10nWdca.add_ad + '" class="thickbox" id="add_ad" href="#TB_inline?width=640&height=594&inlineId=wdca_ad_container">' +
'<img class="button" onclick="return false;" alt="' + l10nWdca.add_ad + '" src="' + _wdca_data.root_url + '/img/ad.png">' +
'</a>'
);
Expand Down
3 changes: 0 additions & 3 deletions lib/class_wdca_admin_pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ function register_mode_settings ($mode) {
$form = new Wdca_AdminFormRenderer($mode);

register_setting($mode, $mode);
//add_settings_section('wdca_settings', __('Benutzerdefinierte Anzeigen', 'wdca'), create_function('', ''), "{$mode}-options");
add_settings_section('wdca_settings', __('Benutzerdefinierte Anzeigen', 'wdca'), function() {}, "{$mode}-options");
add_settings_field('wdca_enable', __('Aktiviere Benutzerdefinierte Anzeigen', 'wdca'), array($form, 'create_enabled_box'), "{$mode}-options", 'wdca_settings');
add_settings_field('wdca_test', __('Live Modus', 'wdca'), array($form, 'create_live_mode_box'), "{$mode}-options", 'wdca_settings');
Expand All @@ -85,7 +84,6 @@ function register_mode_settings ($mode) {
add_settings_field('wdca_ad_delay', __('Verzögertes Einfügen von Anzeigen', 'wdca'), array($form, 'create_ad_show_after_box'), "{$mode}-options", 'wdca_settings');
add_settings_field('wdca_predefined_positions', __('Vordefinierte Positionen', 'wdca'), array($form, 'create_predefined_positions_box'), "{$mode}-options", 'wdca_settings');

//add_settings_section('wdca_appearance', __('Aussehen &amp; Mitteilungen', 'wdca'), create_function('', ''), "{$mode}-options");
add_settings_section('wdca_appearance', __('Aussehen &amp; Mitteilungen', 'wdca'), function() {}, "{$mode}-options");
add_settings_field('wdca_theme', __('Theme', 'wdca'), array($form, 'create_theme_box'), "{$mode}-options", 'wdca_appearance');
add_settings_field('wdca_messages', __('Mitteilungen', 'wdca'), array($form, 'create_messages_box'), "{$mode}-options", 'wdca_appearance');
Expand All @@ -96,7 +94,6 @@ function register_mode_settings ($mode) {
add_settings_field('wdca_ga_category', __('Ereigniskategorie', 'wdca'), array($form, 'create_ga_category_box'), "{$mode}-options", 'wdca_analytics');
add_settings_field('wdca_ga_label', __('Ereignislabel', 'wdca'), array($form, 'create_ga_label_box'), "{$mode}-options", 'wdca_analytics');

//add_settings_section('wdca_advanced', __('Erweitert', 'wdca'), create_function('', ''), "{$mode}-options");
add_settings_section('wdca_advanced', __('Erweitert', 'wdca'), function() {}, "{$mode}-options");
add_settings_field('wdca_allow_post_types', __('Benutzerdefinierte Beitragstypen Anzeigen', 'wdca'), array($form, 'create_cpt_ads_box'), "{$mode}-options", 'wdca_advanced');
add_settings_field('wdca_post_metabox', __('Beitrag Metabox anzeigen', 'wdca'), array($form, 'create_post_metabox_box'), "{$mode}-options", 'wdca_advanced');
Expand Down
33 changes: 13 additions & 20 deletions lib/class_wdca_custom_ad.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,18 @@ public function add_meta_boxes () {
);
}

public function render_link_box () {
global $post;
$link = get_post_meta($post->ID, 'wdca_plugin_url', true);
echo '<p><label for="wdca_plugin_url">' . __('Link URL', 'wdca') . '</label>';
echo "<input type='text' name='wdca_plugin_url' id='wdca_plugin_url' class='widefat' value='{$link}' /></p>";
}

public function render_appearance_box () {
public function render_appearance_box() {
global $post;
$appearance = get_post_meta($post->ID, 'wdca_appearance', true);
// add check to ensure $appearance is an array

// Überprüfen, ob $appearance ein Array ist
if (is_array($appearance)) {
$title = @$appearance['hide_title'] ? 'checked="checked"' : '';
$body = @$appearance['hide_body'] ? 'checked="checked"' : '';
$footer = @$appearance['hide_footer'] ? 'checked="checked"' : '';
$strip_class = @$appearance['strip_class'] ? 'checked="checked"' : '';
$title = isset($appearance['hide_title']) && $appearance['hide_title'] ? 'checked="checked"' : '';
$body = isset($appearance['hide_body']) && $appearance['hide_body'] ? 'checked="checked"' : '';
$footer = isset($appearance['hide_footer']) && $appearance['hide_footer'] ? 'checked="checked"' : '';
$strip_class = isset($appearance['strip_class']) && $appearance['strip_class'] ? 'checked="checked"' : '';
} else {
// handle the case where $appearance is not an array
// Wenn $appearance keine Array ist, setzen Sie die Werte auf Standardwerte oder leere Zeichenfolgen
$title = '';
$body = '';
$footer = '';
Expand All @@ -155,22 +148,22 @@ public function render_appearance_box () {
'<input type="hidden" name="wdca_appearance[hide_title]" value="0" />' .
"<input type='checkbox' name='wdca_appearance[hide_title]' id='wdca_appearance-hide_title' value='1' {$title} /> " .
'<label for="wdca_appearance-hide_title">' . __('Titel nicht anzeigen', 'wdca') . '</label>' .
'</p>';
'</p>';
echo '<p>' .
'<input type="hidden" name="wdca_appearance[hide_body]" value="0" />' .
"<input type='checkbox' name='wdca_appearance[hide_body]' id='wdca_appearance-hide_body' value='1' {$body} /> " .
'<label for="wdca_appearance-hide_body">' . __('Inhalt nicht anzeigen', 'wdca') . '</label>' .
'</p>';
echo '<p>'.
'</p>';
echo '<p>' .
'<input type="hidden" name="wdca_appearance[hide_footer]" value="0" />' .
"<input type='checkbox' name='wdca_appearance[hide_footer]' id='wdca_appearance-hide_footer' value='1' {$footer} /> " .
'<label for="wdca_appearance-hide_footer">' . __('Footer nicht anzeigen', 'wdca') . '</label>' .
'</p>';
'</p>';
echo '<p>' .
'<input type="hidden" name="wdca_appearance[strip_class]" value="0" />' .
"<input type='checkbox' name='wdca_appearance[strip_class]' id='wdca_appearance-strip_class' value='1' {$strip_class} /> " .
'<label for="wdca_appearance-strip_class">' . __('Standardstil entfernen', 'wdca') . '</label>' .
'</p>';
'</p>';
}

public function save_ad_meta () {
Expand Down
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://n3rds.work/spendenaktionen/unterstuetze-unsere-psource-free
Tags: multisite, ads, in-post, werbung, classicpress-plugin
Requires at least: 4.9
Tested up to: 5.6
Stable tag: 1.5.9
Stable tag: 1.6.0
Requires PHP: 7.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -39,7 +39,6 @@ Offer registered users an ad-free reading experience and encourage visitors to u


[Projektseite](https://n3rds.work/cp_psource/ps-beitragsads-plugin/)
[Supportforum](https://n3rds.work/forum/ps-beitragsads-supportforum/)
[GitHub](https://github.com/cp-psource/ps-post-ads)

[POWERED BY PSOURCE](https://n3rds.work/psource_kategorien/cp-powersource/)
Expand Down Expand Up @@ -90,6 +89,10 @@ Make a [donation by bank transfer or PayPal](https://n3rds.work/spenderaktionen/

== ChangeLog ==

= 1.6.0 =

* Fixes for PhP8

= 1.5.9 =

* Fix: Uncaught TypeError: Cannot access offset of type string on string
Expand Down

0 comments on commit 7e8a988

Please sign in to comment.