polarone
Forum Replies Created
-
Forum: Plugins
In reply to: [Filter Everything — Product Filter & WordPress Filter] Pass selected valuesThanks for the answer!
It’s a shame, because everything worked fine except for this.The code has undergone its baptism of fire, it works.
But that’s just it hack \ workaroundI made a hack.
Checks certain categories and in case of 404 error sends a message to the mail and re-saves the settings.Initially I did it in the root directory and protected the file via .htaccess, but for some reason when running on cron the settings were not saved, although the script worked. Apparently something with the rights (didn’t figure it out).
I did it via a snippet. In this code, logging and sending a message after saving the settings are cut out. It works with a test 404 error, but I haven’t had a chance to check it with a real one yet.
// Adding a new interval for the cron (60 seconds)
add_filter('cron_schedules', function ($schedules) {
$schedules['60sec'] = array(
'interval' => 60,
'display' => __('Every 60 seconds'),
);
return $schedules;
});
// Schedule a cron event on initialization
add_action('init', function() {
if (!wp_next_scheduled('check_urls_cron_event')) {
wp_schedule_event(time(), '60sec', 'check_urls_cron_event');
}
});
// Cron event handler
add_action('check_urls_cron_event', function() {
// Список URL-адресов для проверки
$urls = [
'https://site.com/category/',
'https://site.com/category_1/',
'https://site.com/category_2/'
];
// Email, to which the notification will be sent
$to = 'Your_Email@gmail.com';
// Letter subject
$subject = 'Subject 404';
// Function to check page status
function checkUrl($url) {
$headers = @get_headers($url);
if ($headers && strpos($headers[0], '404') !== false) {
return '404 Not Found';
}
return 'OK';
}
// We check all URLs and collect statuses
$statusMessages = [];
$has404Error = false;
foreach ($urls as $url) {
$status = checkUrl($url);
$statusMessages[] = "$url: $status";
if ($status === '404 Not Found') {
$has404Error = true;
}
}
// Execute script if 404 errors are found
if ($has404Error) {
// Executing the script
require_once(ABSPATH . 'wp-load.php');
// Checking if WordPress is loaded
if (function_exists('get_option')) {
// Get current permanent link settings
$current_permalink_structure = get_option('permalink_structure');
// New permanent link structure
$new_permalink_structure = '/%postname%/';
// Updating the structure of permanent links
$result = update_option('permalink_structure', $new_permalink_structure);
// Rewriting rewriting rules (rewrite rules)
global $wp_rewrite;
if (is_object($wp_rewrite) && method_exists($wp_rewrite, 'flush_rules')) {
$wp_rewrite->flush_rules();
}
// Send email after saving settings
$message = "The status of the checked URLs is as follows:\n\n" . implode("\n", $statusMessages);
mail($to, $subject, $message);
}
}
});Still didn’t help. Rarely, but this error is repeated.
Hello @robfrtlz .
Thank you.
Yes, the problem was related to opcache.
Via phpopcache_reset();
I reset the cache and so far the error has not been observed.
I left memcache. Memcached and opcache were also enabled (now disabled). Maybe there is a problem with php and opcache?
Forum: Plugins
In reply to: [Code Snippets] shortcode inside php<?php echo do_shortcode( '[your_shortcode]' ); ?>
But in general the question is not entirely clear.
You can display the shortcode via PHP – the code above.
You can create your own shortcode using snippets.
You can display a shortcode via PHP in a specific place on the site using hooks.add_action('HOOK', 'your_shortcode_function'); function your_shortcode_function() { echo do_shortcode('[your_shortcode]'); }
- This reply was modified 1 year, 3 months ago by polarone.
Forum: Plugins
In reply to: [Code Snippets] Could not create snippet. Request failed with status code 500I’m seeing the same problem.
Even without code. I see a number of problems, but it’s easier to give you the log:[03-Dec-2023 01:12:21 UTC] WordPress database error Invalid default value for 'modified' for query CREATE TABLE zdcu_snippets ( id BIGINT(20) NOT NULL AUTO_INCREMENT, name TINYTEXT NOT NULL, description TEXT NOT NULL, code LONGTEXT NOT NULL, tags LONGTEXT NOT NULL, scope VARCHAR(15) NOT NULL DEFAULT 'global', priority SMALLINT NOT NULL DEFAULT 10, active TINYINT(1) NOT NULL DEFAULT 0, modified DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, revision BIGINT(20) NOT NULL DEFAULT 1, cloud_id VARCHAR(255) NULL, PRIMARY KEY (id), KEY scope (scope), KEY active (active) ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci made by do_action('load-snippets_page_add-snippet'), WP_Hook->do_action, WP_Hook->apply_filters, Code_Snippets\Edit_Menu->load, Code_Snippets\Admin_Menu->load, Code_Snippets\DB::create_missing_table, Code_Snippets\DB::create_table, dbDelta [03-Dec-2023 01:12:21 UTC] WordPress database error Table 'SITE.zdcu_snippets' doesn't exist for query SELECT tags FROM zdcu_snippets made by require_once('wp-admin/admin-header.php'), do_action('admin_enqueue_scripts'), WP_Hook->do_action, WP_Hook->apply_filters, Code_Snippets\Edit_Menu->enqueue_assets, Code_Snippets\get_all_snippet_tags [03-Dec-2023 01:12:32 UTC] WordPress database error Table 'SITE.zdcu_snippets' doesn't exist for query SHOW FULL COLUMNS FROM
zdcu_snippets
made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, rest_api_loaded, WP_REST_Server->serve_request, WP_REST_Server->dispatch, WP_REST_Server->respond_to_request, Code_Snippets\REST_API\Snippets_REST_Controller->create_item, Code_Snippets\save_snippetwordpress 6.4.1
Code Snippets 3.6.2
I use OpenServer:
Apache
php 7.4
MySQL 5.5- This reply was modified 1 year, 3 months ago by polarone.
Forum: Plugins
In reply to: [WooCommerce] Search Attribute request at least 3 charactersexactly the same problem! The list of attributes has ceased to be displayed – it has become terribly inconvenient!
sorry i posted in the wrong place
Forum: Plugins
In reply to: [PWF - Products Filter for WooCommerce] Working with vpmlWhen I select a value in the filter, the link does not change. A get request is not included in the link. And in the demo version, I did not notice this either.
This is important to me, but I still can’t figure out how it works.Forum: Plugins
In reply to: [PWF - Products Filter for WooCommerce] Working with vpmlThank you! I followed the instructions and it turned out to run the plugin. This is sufficient for demonstration and testing purposes.
Only I could not see the functionality of the links live anywhere, I only found it in the description.Pretty URL. For example, yoursite/product-catgory-clothing/color-red/
Clean URL. For example, yoursite/?product-catgory=clothing&color=redThanks anyway! We will switch to pro
Forum: Plugins
In reply to: [PWF - Products Filter for WooCommerce] Working with vpmlFound your instructions site… /plugins/pwfwoofilter/compatible-plugins.html#wpml . I saw that the free version is less than the declared one and made it through the code. Earned. But it’s kind of hard enough. And if a lot of them are planned – you can get tired. Nowhere did I see how the links work in the paid version. But I can at least find a description if I dig.
Thinking, probably the mechanism for updating their accounting program is to blame. It updates all the options, and simply erases the ones created on the site.
Forum: Plugins
In reply to: [Bulk menu creator] Question about functionalityOo! I’m not talking about the frontend. I’m talking about the administration ))
- This reply was modified 1 year, 11 months ago by polarone.