Forum Replies Created

Viewing 15 replies - 1 through 15 (of 46 total)
  • Thread Starter neikoloves

    (@neikoloves)

    Thank you for your response! It seems we have a bit of a conflict regarding the theme. Could you provide any additional documentation on this or a known working sample? Specifically, I’m curious if your search overwrites the integrated theme search with your search or if it operates independently somehow? Maybe we have too much logic and it conflicts when trying to combine the filters args? Thanks

    • This reply was modified 1 month, 4 weeks ago by neikoloves.
    Thread Starter neikoloves

    (@neikoloves)

    Ok here is my starting point, needs some more refinements, but it does do some things, I was looking for, maybe this can be useful for the cause?

    <?php

    /**
    * Docket Cache Controls Dashboard Widget
    *
    * Version: 1.0.0
    * This code adds a custom dashboard widget to the WordPress admin area that allows administrators
    * to execute Docket Cache controls and provides real-time status updates.
    *
    * BBOL "Be Blessed, Open License". https://www.gotquestions.org/mean-to-be-blessed.html
    *
    */

    // Register the dashboard widget
    function register_docket_cache_dashboard_widget() {
    wp_add_dashboard_widget(
    'docket_cache_dashboard_widget', // Widget ID
    'Docket Cache Controls', // Widget Title
    'render_docket_cache_dashboard_widget_content' // Callback function to render content
    );
    }
    add_action('wp_dashboard_setup', 'register_docket_cache_dashboard_widget');

    // Render the widget content
    function render_docket_cache_dashboard_widget_content() {
    $nonce = wp_create_nonce('docket_cache_action_nonce');
    ?>
    <div id="docket-cache-widget">
    <div class="docket-cache-buttons-container">
    <?php
    $buttons = [
    'flush_cache' => 'Flush Cache',
    'flush_precache' => 'Flush PreCache',
    'flush_menucache' => 'Flush Menu Cache',
    'flush_mocache' => 'Flush MoCache',
    'flush_transient' => 'Flush Transients',
    'update_dropin' => 'Update Drop-In',
    'enable_dropin' => 'Enable Drop-In',
    'disable_dropin' => 'Disable Drop-In',
    'runtime_install' => 'Install Runtime',
    'runtime_uninstall' => 'Remove Runtime',
    'optimizedb' => 'Optimize DB',
    ];

    foreach ($buttons as $action => $label) {
    echo '<div class="docket-cache-button-container">';
    echo '<button class="docket-cache-button" data-action="' . esc_attr($action) . '">' . esc_html($label) . '</button>';
    echo '<div class="docket-cache-status" id="status-' . esc_attr($action) . '">Status: Pending</div>';
    echo '</div>';
    }
    ?>
    </div>
    <div id="docket-cache-response"></div>
    </div>
    <style>
    #docket-cache-widget {
    padding: 10px;
    }
    .docket-cache-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    }
    .docket-cache-button-container {
    flex: 1 1 calc(33.33% - 10px);
    text-align: center;
    min-width: 120px;
    }
    .docket-cache-button {
    padding: 6px 10px;
    background-color: #a30000; /* Red color */
    color: #fff;
    border: none;
    cursor: pointer;
    border-radius: 3px;
    font-size: 12px;
    width: 100%;
    box-sizing: border-box;
    transition: background-color 0.3s ease;
    }
    .docket-cache-button:hover {
    background-color: #c63c3c; /* Lighten red on hover */
    }
    .docket-cache-button.success {
    background-color: #2a7d2f; /* Green color for success */
    }
    .docket-cache-status {
    margin-top: 5px;
    font-size: 12px;
    color: #666;
    }
    .docket-cache-status.success {
    color: #2a7d2f; /* Green color for success */
    }
    .docket-cache-status.error {
    color: #a30000; /* Red color for error */
    }
    #docket-cache-response {
    margin-top: 10px;
    font-size: 14px;
    color: #444;
    }
    </style>
    <script>
    (function($) {
    $('.docket-cache-button').on('click', function() {
    var action = $(this).data('action');
    var nonce = '<?php echo $nonce; ?>';
    var $button = $(this);
    var $statusElement = $('#status-' + action);
    var originalText = $button.text();

    $('.docket-cache-button').prop('disabled', true);
    $button.removeClass('success').text('Executing...');
    $statusElement.removeClass('success error').text('Status: Executing...');

    $.post(ajaxurl, {
    action: 'execute_docket_cache_action',
    nonce: nonce,
    custom_action: action
    }, function(response) {
    if (response.success) {
    var message = response.data.message;
    var timestamp = response.data.timestamp;
    $statusElement.addClass('success').html('Status: ' + message + '<br>' + timestamp);
    $button.addClass('success').text(originalText);
    } else {
    $statusElement.addClass('error').html('Status: Error - ' + response.data.message + '<br>' + response.data.timestamp);
    $button.removeClass('success').text('Failed');
    }

    // Hide the status message after 5 seconds
    setTimeout(function() {
    $statusElement.text('Status: Pending');
    $button.removeClass('success').text(originalText);
    }, 5000);

    }).fail(function(xhr, textStatus, errorThrown) {
    console.error('AJAX Error:', textStatus, errorThrown);
    $statusElement.addClass('error').html('Status: Error - ' + textStatus + ' - ' + errorThrown + '<br>' + new Date().toLocaleString());
    $button.removeClass('success').text('Failed');

    // Hide the status message after 5 seconds
    setTimeout(function() {
    $statusElement.text('Status: Pending');
    $button.removeClass('success').text(originalText);
    }, 5000);

    }).always(function() {
    $('.docket-cache-button').prop('disabled', false);
    });
    });
    })(jQuery);
    </script>
    <?php
    }

    // Handle AJAX request for executing Docket Cache actions
    function handle_docket_cache_action() {
    if ( !isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'docket_cache_action_nonce') ) {
    wp_send_json_error(['message' => 'Nonce verification failed.']);
    }

    if ( !current_user_can('manage_options') ) {
    wp_send_json_error(['message' => 'Insufficient permissions.']);
    }

    $action = isset($_POST['custom_action']) ? sanitize_text_field($_POST['custom_action']) : '';

    $action_hooks = [
    'flush_cache' => 'docket_cache_control_flush_cache',
    'flush_precache' => 'docket_cache_control_flush_precache',
    'flush_menucache' => 'docket_cache_control_flush_menucache',
    'flush_mocache' => 'docket_cache_control_flush_mocache',
    'flush_transient' => 'docket_cache_control_flush_transient',
    'update_dropin' => 'docket_cache_control_update_dropin',
    'enable_dropin' => 'docket_cache_control_enable_dropin',
    'disable_dropin' => 'docket_cache_control_disable_dropin',
    'runtime_install' => 'docket_cache_control_runtime_install',
    'runtime_uninstall' => 'docket_cache_control_runtime_uninstall',
    'optimizedb' => 'docket_cache_control_optimizedb',
    ];

    if (!array_key_exists($action, $action_hooks)) {
    wp_send_json_error(['message' => 'Unknown action.']);
    }

    ob_start();
    do_action($action_hooks[$action]);
    $output = ob_get_clean();

    $success_messages = [
    'flush_cache' => 'Cache flushed',
    'flush_precache' => 'PreCache flushed',
    'flush_menucache' => 'Menu cache flushed',
    'flush_mocache' => 'Mo cache flushed',
    'flush_transient' => 'Transients flushed',
    'update_dropin' => 'Drop-In updated',
    'enable_dropin' => 'Drop-In enabled',
    'disable_dropin' => 'Drop-In disabled',
    'runtime_install' => 'Runtime installed',
    'runtime_uninstall' => 'Runtime removed',
    'optimizedb' => 'Database optimized',
    ];

    $message = isset($success_messages[$action]) ? $success_messages[$action] : 'Action executed successfully.';
    $timestamp = current_time('mysql');
    $formatted_timestamp = date('m/d/y g:i:sa', strtotime($timestamp)); // Adjusted format

    wp_send_json_success([
    'message' => $message . '. ' . $output,
    'timestamp' => $formatted_timestamp
    ]);
    }
    add_action('wp_ajax_execute_docket_cache_action', 'handle_docket_cache_action');

    // Actions to handle Docket Cache controls
    add_action('docketcache/init', function($docket_cache_instance) {
    $docket_cache = $docket_cache_instance;

    // Flush cache
    add_action('docket_cache_control_flush_cache', function() use($docket_cache) {
    try {
    $result = $docket_cache->flush_cache(true);
    $docket_cache->co()->lookup_set('occacheflushed', $result);
    do_action('docketcache/action/flush/objectcache', 'Cache flushed');
    } catch (Exception $e) {
    error_log('Error flushing cache: ' . $e->getMessage());
    do_action('docketcache/action/flush/objectcache', 'Error: ' . $e->getMessage());
    }
    });

    // Enable Drop-In
    add_action('docket_cache_control_enable_dropin', function() use($docket_cache) {
    try {
    $result = $docket_cache->cx()->install(true);
    do_action('docketcache/action/enable/objectcache', 'Drop-In enabled');
    } catch (Exception $e) {
    error_log('Error enabling drop-in: ' . $e->getMessage());
    do_action('docketcache/action/enable/objectcache', 'Error: ' . $e->getMessage());
    }
    });

    // Disable Drop-In
    add_action('docket_cache_control_disable_dropin', function() use($docket_cache) {
    try {
    $result = $docket_cache->cx()->uninstall();
    do_action('docketcache/action/disable/objectcache', 'Drop-In disabled');
    } catch (Exception $e) {
    error_log('Error disabling drop-in: ' . $e->getMessage());
    do_action('docketcache/action/disable/objectcache', 'Error: ' . $e->getMessage());
    }
    });

    // Update Drop-In
    add_action('docket_cache_control_update_dropin', function() use($docket_cache) {
    try {
    $result = $docket_cache->cx()->install(true);
    do_action('docketcache/action/update/objectcache', 'Drop-In updated');
    } catch (Exception $e) {
    error_log('Error updating drop-in: ' . $e->getMessage());
    do_action('docketcache/action/update/objectcache', 'Error: ' . $e->getMessage());
    }
    });

    // Flush Menu Cache
    add_action('docket_cache_control_flush_menucache', function() use($docket_cache) {
    try {
    $result = 0;
    $ok = false;
    if (function_exists('wp_cache_flush_group') && method_exists('WP_Object_Cache', 'dc_remove_group')) {
    $result = wp_cache_flush_group('docketcache-menu');
    $docket_cache->co()->lookup_set('menucacheflushed', $result);
    $ok = true;
    }
    do_action('docketcache/action/flush/file/menucache', $ok ? 'Menu cache flushed' : 'Error');
    } catch (Exception $e) {
    error_log('Error flushing menu cache: ' . $e->getMessage());
    do_action('docketcache/action/flush/file/menucache', 'Error: ' . $e->getMessage());
    }
    });

    // Flush Mo Cache
    add_action('docket_cache_control_flush_mocache', function() use($docket_cache) {
    try {
    $result = 0;
    $ok = false;
    if (function_exists('wp_cache_flush_group') && method_exists('WP_Object_Cache', 'dc_remove_group')) {
    $result = wp_cache_flush_group('docketcache-mo');
    $docket_cache->pt->co()->lookup_set('mocacheflushed', $result);
    $ok = true;
    }
    do_action('docketcache/action/flush/file/mocache', $ok ? 'Mo cache flushed' : 'Error');
    } catch (Exception $e) {
    error_log('Error flushing Mo cache: ' . $e->getMessage());
    do_action('docketcache/action/flush/file/mocache', 'Error: ' . $e->getMessage());
    }
    });

    // Flush PreCache
    add_action('docket_cache_control_flush_precache', function() use($docket_cache) {
    try {
    $result = 0;
    $ok = false;
    if (function_exists('wp_cache_flush_group') && method_exists('WP_Object_Cache', 'dc_remove_group')) {
    $result = wp_cache_flush_group('docketcache-precache');
    $docket_cache->pt->co()->lookup_set('ocprecacheflushed', $result);
    $ok = true;
    }
    do_action('docketcache/action/flush/file/ocprecache', $ok ? 'PreCache flushed' : 'Error');
    } catch (Exception $e) {
    error_log('Error flushing PreCache: ' . $e->getMessage());
    do_action('docketcache/action/flush/file/ocprecache', 'Error: ' . $e->getMessage());
    }
    });

    // Flush Transients
    add_action('docket_cache_control_flush_transient', function() use($docket_cache) {
    try {
    global $wpdb;
    $result = $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_%'");
    $docket_cache->pt->co()->lookup_set('transientflushed', $result);
    do_action('docketcache/action/flush/file/transient', 'Transients flushed');
    } catch (Exception $e) {
    error_log('Error flushing transients: ' . $e->getMessage());
    do_action('docketcache/action/flush/file/transient', 'Error: ' . $e->getMessage());
    }
    });

    // Optimize DB
    add_action('docket_cache_control_optimizedb', function() use($docket_cache) {
    try {
    $result = (new Nawawi\DocketCache\Event($docket_cache))->optimizedb();
    do_action('docketcache/action/event/optimizedb', 'Database optimized');
    } catch (Exception $e) {
    error_log('Error optimizing database: ' . $e->getMessage());
    do_action('docketcache/action/event/optimizedb', 'Error: ' . $e->getMessage());
    }
    });

    // Install Runtime Code
    add_action('docket_cache_control_runtime_install', function() use($docket_cache) {
    try {
    $result = Nawawi\DocketCache\WpConfig::runtime_install();
    do_action('docketcache/action/updatewpconfig', 'Runtime installed');
    } catch (Exception $e) {
    error_log('Error installing runtime code: ' . $e->getMessage());
    do_action('docketcache/action/updatewpconfig', 'Error: ' . $e->getMessage());
    }
    });

    // Uninstall Runtime Code
    add_action('docket_cache_control_runtime_uninstall', function() use($docket_cache) {
    try {
    $result = Nawawi\DocketCache\WpConfig::runtime_remove();
    do_action('docketcache/action/updatewpconfig', 'Runtime removed');
    } catch (Exception $e) {
    error_log('Error uninstalling runtime code: ' . $e->getMessage());
    do_action('docketcache/action/updatewpconfig', 'Error: ' . $e->getMessage());
    }
    });
    });
    Thread Starter neikoloves

    (@neikoloves)

    Hello, update I went looking for the issue and for now, I did this and it worked in the file below >

    wp-content/plugins/woo-custom-gateway/src/WooCustomGateway.php

    // request rating
    // $this->add_filter(‘admin_notices’, $controller, ‘showAdminNotices’);

    Thank you again…

    I also am looking for this standard, please let me know when this is released and thank you for all your efforts.

    Thread Starter neikoloves

    (@neikoloves)

    ^ Bump, thank you.

    @jm47 Did this method work for you? Seems these days we are flying blind with updates, unless you take control of the source and see the diffs, things will break that once worked perfectly. Thanks

    It looks like all you need to do is add a declaration like… ??

    // Declare support for features
    	add_action( 'before_woocommerce_init', function () {
    		if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
    			\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
    		}
    	} );

    Also interested in this please, thank you so much.

    Hello, first I wanted to thank you ever so much for the great plugin. I have a similar issue and we have the hosting company investigating this now.

    We do not have an issue with anything else related, so it’s some conflict. And this is a fairly new issue as well, it used to work just fine.

    Something must have changed at the caching layer end, we also use Object Caching Pro if that helps built in, maybe that in part is the issue, but can’t disable it or we become slower.

    Error 503 Backend fetch failed
    Backend fetch failed
    
    Guru Meditation:
    XID: 21254546
    
    Varnish cache server
    • This reply was modified 1 year, 12 months ago by neikoloves.
    Thread Starter neikoloves

    (@neikoloves)

    Hello,

    The issue I have is the idea is great but the page you are sent too is just not very professional looking, why can’t we just use the default themes pages?

    That is a much more polished UI and we have full control over that display in the theme options.

    Also in looking at your paid plugin, can I see the demo for this somehow?

    Thanks and best regards…

    Thread Starter neikoloves

    (@neikoloves)

    @kevindees seems like we are limited with a tree dig like I would love to see.

    REF: https://developer.www.ads-software.com/reference/functions/register_post_type/#publicly_queryable

    The plugin Custom Post Type Editor at least does the lookup needed with some data display, but not much of a deeper outlined flowchart.

    Trying to learn coming from dedicated fields with dedicated databases for any function that just call relational tables. Seems the WP/WC data needs segmented more, but I’m not yet sure how to do that?

    Thanks again.

    @disablebloat @sudarshankotian It’s great to know this is only a false positive. The licencing system is just a mess, not an easy one to solve I guess. Seems to be buggy at best. Thanks for the updates guys.

    Thread Starter neikoloves

    (@neikoloves)

    @fullstackhouse Thank you for looking at this post, we resolved this by creating our own custom snippet that also supports the Gutenberg editor, custom post types and with less than 80 lines of code.

    Thread Starter neikoloves

    (@neikoloves)

    @laragoogleanalytics I read what you are saying, but there is no place to allow us to use UA anymore, trust me I tried and it’s just been removed with a notice that they no longer support new UA analytics setup>

    So there is where the issue is sadly, I can’t even test this, the option is seemly greyed out as they already have me setup under a GA4 setup.

    Will try to setup another account as you are stating is likely the issue and see if that helps, Google is a pain sometimes, what a nested hot mess, I can’t even understand why they have to make such a nested mess of an application with way too many options.

    Please advise and thank you kindly for your support.

    • This reply was modified 2 years, 1 month ago by neikoloves.

    @sudarshankotian I would also like to know, I tested the same with the pro version and see the same results. Seems PHP 8 is really not ready for use sadly. )o;

Viewing 15 replies - 1 through 15 (of 46 total)