ct_catcbc_premium_plugin();
}
?>
id, $this->get_tab_screen_ids(), true)) {
$tabs = array(
'rules' => array(
'title' => __('Rules', 'add-to-cart-button-customizer'),
'url' => admin_url('edit.php?post_type=ct_cstm_add_t_c_btn'),
),
'ct_catcbc_premium_plugin' => array(
'title' => __(' Our Premium Plugin ', 'add-to-cart-button-customizer'),
'url' => admin_url('admin.php?page=ct_catcbc_setting&tab=ct_catcbc_premium_plugin'),
),
);
if (is_array($tabs)) {
?>
get_current_tab();
if ( isset($_GET['tab'])) {
$current_tab = sanitize_text_field( $_GET['tab'] );
}
foreach ($tabs as $id => $tab_data) {
$class = $id === $current_tab ? array('nav-tab', 'nav-tab-active') : array('nav-tab');
printf('%3$s', esc_url($tab_data['url']), implode(' ', array_map('sanitize_html_class', $class)), esc_html($tab_data['title'] ));
}
?>
id;
switch ( $active_tab ) {
case 'woocommerce_page_ct_catcbc_setting':
return 'general_setting';
case 'ct_cstm_add_t_c_btn':
case 'edit-ct_cstm_add_t_c_btn':
return 'rules';
}
}
/**
* Adding columns in custom post type table .
* All Screens
*/
public function get_tab_screen_ids() {
$tabs_screens = array(
'woocommerce_page_ct_catcbc_setting',
'edit-ct_cstm_add_t_c_btn',
'ct_cstm_add_t_c_btn',
);
return $tabs_screens;
}
public function ct_catcbc_premium_plugin() {
$apiUrl = 'https://cloudtechnologies.store/wp-json/custom-woocommerce-api/v1/products/woocommerce';
$curl = curl_init($apiUrl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
if ($response) {
$products_details = json_decode($response, true);
?>
|
|
|
|
|
$current_product_detail):
if ( ! is_array( $current_product_detail ) ) {
continue;
}
$product_name = isset( $current_product_detail['product_name'] ) ? $current_product_detail['product_name'] : '';
$product_url = isset( $current_product_detail['product_url'] ) ? $current_product_detail['product_url'] : '';
$regular_price = isset( $current_product_detail['regular_price'] ) ? $current_product_detail['regular_price'] : '';
$sale_price = isset( $current_product_detail['sale_price'] ) ? $current_product_detail['sale_price'] : '';
$review = isset( $current_product_detail['review'] ) ? $current_product_detail['review'] : '';
$short_description = isset( $current_product_detail['short_description'] ) ? $current_product_detail['short_description'] : '';
$image = isset( $current_product_detail['image_url'] ) ? $current_product_detail['image_url'] : '';
?>
|
|
$
$
$
|
.
|
|
ID;
if ( 'add_to_cart' === (string) $column ) {
echo esc_attr( get_post_meta( $post_id, 'ct_catcbfw_add_to_cart_button_text', true ) );
}
if ( 'rule_status' === (string) $column ) {
echo esc_attr( ucfirst( get_post_status( $post_id ) ) );
}
if ( 'applied_on' === (string) $column ) {
$applied_on = '';
if ( get_post_meta( get_the_ID(), 'ct_catcbfw_product_included_list', true ) ) {
$applied_on = ' Product ';
}
if ( get_post_meta( get_the_ID(), 'ct_catcbfw_included_category', true ) ) {
$applied_on = ' -- Categories ';
}
if ( get_post_meta( get_the_ID(), 'ct_catcbfw_product_tags', true ) ) {
$applied_on = ' -- Tag ';
}
$applied_on = ! empty( $applied_on ) ? $applied_on : 'For All Product';
echo esc_attr( $applied_on );
}
}
/**
* Adding MEta Box.
*/
public function cloud_catcbfw_create_metabox() {
add_meta_box(
'ct_catcbfw_restrictions',
esc_html__( 'Restrictions', 'add-to-cart-button-customizer' ),
array( $this, 'restriction' ),
'ct_cstm_add_t_c_btn'
);
add_meta_box(
'ct_catcbfw_add_to_cart_styling',
esc_html__( 'Add To Cart Styling', 'add-to-cart-button-customizer' ),
array( $this, 'add_to_cart_styling' ),
'ct_cstm_add_t_c_btn'
);
add_meta_box(
'ct_catcbfw_add_to_cart_styling',
esc_html__( 'Add To Cart Styling', 'add-to-cart-button-customizer' ),
array( $this, 'add_to_cart_styling' ),
'product',
);
}
/**
* Restrict callback.
*/
public function restriction() {
global $wp_roles;
wp_nonce_field( 'ct_catcbfw_nonce', 'ct_catcbfw_nonce' );
$countries_obj = new WC_Countries();
$countries = $countries_obj->__get( 'countries' );
$af_a_and_va_s_product_tags = get_terms( array( 'taxonomy' => 'product_tag' ) );
$included_product = (array) get_post_meta( get_the_ID(), 'ct_catcbfw_product_included_list', true );
$excluded_products = (array) get_post_meta( get_the_ID(), 'ct_catcbfw_product_exclusion_list', true );
$selected_categories = (array) get_post_meta( get_the_ID(), 'ct_catcbfw_included_category', true );
$ct_selected_tags = (array) get_post_meta( get_the_ID(), 'ct_catcbfw_product_tags', true );
$add_cart_styling_setting = (array) get_post_meta( get_the_ID(), 'ct_catcbfw_add_to_cart_styling', true );
$switch_from_roles = $wp_roles->get_names();
$switch_from_roles['guest'] = 'Guest';
$kselect_user_roles = (array) get_post_meta( get_the_ID(), 'ct_catcbfw_select_user_from_switch', true );
$ct_catcbfw_select_pages = (array) get_post_meta( get_the_ID(), 'ct_catcbfw_select_pages', true );
$switch_pages = array(
'shop' => 'Shop',
'product_page' => 'Single/ Product Page',
'category_page' => 'Category Page',
'tag_page' => 'Tag Page',
);
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get_names();
$switch_from_roles['guest'] = 'Guest';
$kselect_user_roles = (array) get_post_meta( get_the_ID(), 'ct_catcbfw_select_user_from_switch', true );
$ct_catcbfw_select_pages = (array) get_post_meta( get_the_ID(), 'ct_catcbfw_select_pages', true );
$switch_pages = array(
'shop' => 'Shop',
'product_page' => 'Single/ Product Page',
'category_page' => 'Category Page',
'tag_page' => 'Tag Page',
);
?>
admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'ct_catcbfw_nonce' ),
);
wp_localize_script( 'admin_js', 'php_var', $order_renew );
}
/**
* Product Live Search.
*/
public function ct_catcbfw_product_search() {
$nonce = isset( $_POST['nonce'] ) && ! empty( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : 0;
if ( ! wp_verify_nonce( $nonce, 'ct_catcbfw_nonce' ) ) {
die( 'Failed ajax security check!' );
}
if ( isset( $_POST['q'] ) && ! empty( $_POST['q'] ) ) {
$pro = sanitize_text_field( wp_unslash( $_POST['q'] ) );
} else {
$pro = '';
}
$data_array = array();
$args = array(
'post_type' => array( 'product', 'product_variation' ),
'post_status' => 'publish',
'numberposts' => -1,
's' => $pro,
'type' => array( 'simple', 'variable' ),
'orderby' => 'relevance',
'order' => 'ASC',
);
$pros = wc_get_products( $args );
if ( ! empty( $pros ) ) {
foreach ( $pros as $proo ) {
$title = ( mb_strlen( $proo->get_name() ) > 50 ) ? mb_substr( $proo->get_name(), 0, 49 ) . '...' : $proo->get_name();
$data_array[] = array( $proo->get_id(), $title ); // array( Post ID, Post Title ).
}
}
echo wp_json_encode( $data_array );
die();
}
/**
* Category live search.
*/
public function cloud_catcbfw_category_search() {
$nonce = isset( $_POST['nonce'] ) && ! empty( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : 0;
if ( ! wp_verify_nonce( $nonce, 'ct_catcbfw_nonce' ) ) {
die( 'Failed ajax security check!' );
}
if ( isset( $_POST['q'] ) && ! empty( $_POST['q'] ) ) {
$pro = sanitize_text_field( wp_unslash( $_POST['q'] ) );
} else {
$pro = '';
}
$data_array = array();
$orderby = 'name';
$order = 'asc';
$hide_empty = false;
$cat_args = array(
'orderby' => $orderby,
'order' => $order,
'hide_empty' => $hide_empty,
'name__like' => $pro,
);
$product_categories = get_terms( 'product_cat', $cat_args );
if ( ! empty( $product_categories ) ) {
foreach ( $product_categories as $proo ) {
$pro_front_post = ( mb_strlen( $proo->name ) > 50 ) ? mb_substr( $proo->name, 0, 49 ) . '...' : $proo->name;
$data_array[] = array( $proo->term_id, $pro_front_post ); // array( Post ID, Post Title ).
}
}
echo wp_json_encode( $data_array );
die();
}
}
/**
* Object of Class.
*/
new Catcbfw_Admin();
}