function hocwp_get_post_id_by_slug($slug) { return hocwp_get_post_by_column('post_name', $slug, 'post_id'); }
function hocwp_translate_x_string_transaltion_update() { if (isset($_REQUEST['hocwp_action']) && 'string_translation' == $_REQUEST['hocwp_action']) { unset($_REQUEST['hocwp_action']); $search = hocwp_get_method_value('s', 'request'); $strings = hocwp_get_method_value('strings'); if (hocwp_array_has_value($strings)) { $mo = new HOCWP_MO(); $saved_strings = hocwp_get_registered_string_language(); foreach ($strings as $encrypted_string) { unset($saved_strings[$encrypted_string]); $mo->delete_from_db($encrypted_string, true); } update_option('hocwp_string_translations', $saved_strings); hocwp_delete_transient('hocwp_string_translation_registered'); } $args = array_intersect_key($_REQUEST, array_flip(array('s', 'paged', 'group'))); if (!empty($search)) { $args['s'] = $search; } if (!empty($args['s'])) { $args['s'] = urlencode($args['s']); } $translations = hocwp_get_method_value('translation'); if (hocwp_array_has_value($translations)) { foreach ($translations as $key => $value) { if (!empty($value)) { $mo = hocwp_get_post_by_column('post_title', 'hocwp_mo_' . $key, OBJECT, array('post_type' => 'hocwp_mo')); if (is_a($mo, 'WP_Post')) { $obj = new HOCWP_MO($mo->ID); $obj->export_to_db($mo->post_excerpt, $value); } } } } $url = add_query_arg($args, wp_get_referer()); wp_safe_redirect($url); exit; } }
function hocwp_setup_theme_woocommerce_product_tabs_callback($key, $tab) { $content = hocwp_get_post_meta($key, get_the_ID()); $content = trim($content); $title = hocwp_get_value_by_key($tab, 'title'); if (empty($content)) { $slug = hocwp_sanitize_html_class($key); $hocwp_product_tab = hocwp_get_post_by_slug($slug, 'hocwp_product_tab'); if (!hocwp_is_post($hocwp_product_tab)) { $hocwp_product_tab = hocwp_get_post_by_column('post_title', $title); } if (hocwp_is_post($hocwp_product_tab)) { $content = $hocwp_product_tab->post_content; $content = trim($content); } } if (!empty($content)) { if (!empty($title)) { echo hocwp_wrap_tag($title, 'h2', 'tab-title'); } echo '<div class="hocwp-product-info">'; $embed = new WP_Embed(); $content = $embed->run_shortcode($content); $content = $embed->autoembed($content); hocwp_the_custom_content($content); echo '</div>'; } }