Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Settings error on WP 6.2 #47

Merged
merged 3 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/campaigns_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public static function wpematico_debug_notice() {
if ($post_type != 'wpematico')
return;
$danger_options = WPeMatico::get_danger_options();
if ($danger_options['wpe_debug_logs_campaign']) {
$class = 'notice notice-warning notice-alt';
$message = __('WARNING! WPeMatico Debug mode has been activated at Settings->System Status->Danger Zone.', 'wpematico') . '<br />'
. __('Be sure to deactivate it after your tests to avoid performance issues.', 'wpematico');
printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr($class), $message);
}
if ($danger_options['wpe_debug_logs_campaign']) {
$class = 'notice notice-warning notice-alt';
$message = __('WARNING! WPeMatico Debug mode has been activated at Settings->System Status->Danger Zone.', 'wpematico') . '<br />'
. __('Be sure to deactivate it after your tests to avoid performance issues.', 'wpematico');
printf('<div class="%1$s"><p>%2$s</p></div>', esc_attr($class), $message);
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/lib/wp_ratings.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
$cookie_jar = @tempnam('./tmp','cookie');
$args = array(
'user-agent'=> "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1",
'cookies' => array($cookie_jar)
// 'cookies' => array($cookie_jar)
);

$html = WPeMatico_functions::wpematico_get_contents($url, $args);
//print_r( $html,1 ); //exit;

// remove the cookie jar
unlink($cookie_jar) /*or die("Can't unlink $cookie_jar")*/;
// unlink($cookie_jar) /*or die("Can't unlink $cookie_jar")*/;

if (!$html) {
echo '<div id="reviews">'. __('Can\t connect to Wordpress Site', 'wpematico' ).'</div>';
Expand Down
21 changes: 13 additions & 8 deletions app/wpematico_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
header('HTTP/1.1 403 Forbidden');
exit();
}

if (!class_exists('WPeMatico_functions')) {

class WPeMatico_functions {

public static $current_feed = ''; // The current feed that is running.

/**
Expand Down Expand Up @@ -1581,7 +1579,7 @@ public static function wpematico_get_contents($url, $arg = true) {
$args = wp_parse_args($aux, $defaults);

if (!$data) { // if stil getting error on get file content try WP func, this may give timeouts
$response = wp_remote_request($url, $args);
$response = wp_remote_request($url, $args);
if (!is_wp_error($response)) {
if (isset($response['response']['code']) && 200 === $response['response']['code']) {
$data = wp_remote_retrieve_body($response);
Expand Down Expand Up @@ -1616,13 +1614,20 @@ public static function get_curl_version() {

public static function get_danger_options() {
$danger = get_option('WPeMatico_danger');
$danger['wpemdeleoptions'] = (isset($danger['wpemdeleoptions']) && !empty($danger['wpemdeleoptions']) ) ? $danger['wpemdeleoptions'] : false;
$danger['wpemdelecampaigns'] = (isset($danger['wpemdelecampaigns']) && !empty($danger['wpemdelecampaigns']) ) ? $danger['wpemdelecampaigns'] : false;
$danger['wpe_debug_logs_campaign'] = (isset($danger['wpe_debug_logs_campaign']) && !empty($danger['wpe_debug_logs_campaign']) ) ? $danger['wpe_debug_logs_campaign'] : false;

if(is_array($danger)){
$danger['wpemdeleoptions'] = (isset($danger['wpemdeleoptions']) && !empty($danger['wpemdeleoptions']) ) ? $danger['wpemdeleoptions'] : false;
$danger['wpemdelecampaigns'] = (isset($danger['wpemdelecampaigns']) && !empty($danger['wpemdelecampaigns']) ) ? $danger['wpemdelecampaigns'] : false;
$danger['wpe_debug_logs_campaign'] = (isset($danger['wpe_debug_logs_campaign']) && !empty($danger['wpe_debug_logs_campaign']) ) ? $danger['wpe_debug_logs_campaign'] : false;
}else{
$danger = [];
$danger['wpemdeleoptions'] = false;
$danger['wpemdelecampaigns'] = false;
$danger['wpe_debug_logs_campaign'] = false;
}

return $danger;
}

}

// Class WPeMatico_functions
Expand Down