简体   繁体   English

在 woocommerce 中创建计划任务 (Plesk) 或 cron 作业

[英]Create s scheduled task(Plesk) or cron job in woocommerce

I have a woocommerce and i use berocket product filters plugin.我有一个 woocommerce,我使用 berocket 产品过滤器插件。 The plugin has a button that purge cache in its setting page.该插件在其设置页面中有一个清除缓存的按钮。 I want to create a scheduled task from inside plesk that hosts the woocommerce that trigger that function every 30 minutes.我想从托管 woocommerce 的 plesk 内部创建一个计划任务,每 30 分钟触发一次 function。

I have located,i think, the function that use the above button but i need help creating the scheduled task.我认为,我找到了使用上述按钮的 function,但我需要帮助来创建计划任务。

I have the function in the main.php file located in the root directory of the plugin.我在插件根目录的 main.php 文件中有 function。

public function section_purge_cache ( $item, $options ) {
    $html = '<tr>
        <th scope="row">' . __('Purge Cache', 'BeRocket_AJAX_domain') . '</th>
        <td>';
    $old_filter_widgets = get_option('widget_berocket_aapf_widget');
    if( ! is_array($old_filter_widgets) ) {
        $old_filter_widgets = array();
    }
    foreach ($old_filter_widgets as $key => $value) {
        if (!is_numeric($key)) {
            unset($old_filter_widgets[$key]);
        }
    }
    $html .= '
            <span class="button berocket_purge_cache" data-time="'.time().'">
                <input class="berocket_purge_cache_input" type="hidden" name="br_filters_options[purge_cache_time]" value="'.br_get_value_from_array($options, 'purge_cache_time').'">
                ' . __('Purge Cache', 'BeRocket_AJAX_domain') . '
            </span>
            <p>' . __('Clear attribute/custom taxonomy cache for plugin', 'BeRocket_AJAX_domain') . '</p>
            <script>
                jQuery(".berocket_purge_cache").click(function() {
                    var $this = jQuery(this);
                    if( ! $this.is(".berocket_ajax_sending") ) {
                        $this.attr("disabled", "disabled");
                        var time = $this.data("time");
                        $this.parents(".br_framework_submit_form").addClass("br_reload_form");
                        $this.find(".berocket_purge_cache_input").val(time).submit();
                    }
                });
            </script>
        </td>
    </tr>';
    return $html;
}

Since this is a product from BeRocket i would suggest you to ask this question in the support forum of the plugin itself.由于这是 BeRocket 的产品,我建议您在插件本身的支持论坛中提出这个问题。

Here you go: https://wordpress.org/support/plugin/woocommerce-ajax-filters/给你 go: https://wordpress.org/support/plugin/woocommerce-ajax-filters/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM