add_action( 'wp_enqueue_scripts', 'liquid_child_theme_style', 99 );
function liquid_parent_theme_scripts() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
function liquid_child_theme_style(){
wp_enqueue_style( 'child-one-style', get_stylesheet_directory_uri() . '/style.css?'.time() );
}
/*===============================================================================================
SEGURIDAD
===============================================================================================*/
require_once('_campos.php');
require_once('_carrito.php');
require_once('_vendedores.php');
require_once('_buscador.php');
require_once('_productos.php');
require_once('_cuenta.php');
require_once('_endpoint.php');
require_once('_admin.php');
require_once('_siigo.php');
/*===============================================================================================
LIBRERIAS JS
===============================================================================================*/
function my_theme_scripts_function() {
global $post;
$user = wp_get_current_user();
$admVersion = '';
if( ! empty( $user ) && in_array( "administrator", (array) $user->roles ) ) {
$admVersion = '?'.time();
}
wp_enqueue_script( 'myscript', get_stylesheet_directory_uri() . '/js/site.js'.$admVersion,'','',true);
wp_localize_script( 'myscript', 'ajax_var', array(
'url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'my-ajax-nonce' ),
'pageCurrent' => $post->post_name
));
}
add_action('wp_enqueue_scripts','my_theme_scripts_function', 99);
/*
remove_action('wp_head', 'wp_generator');
function wpb_remove_version() {
return '';
}
add_filter('the_generator', 'wpb_remove_version');
function disable_emojis() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
// Remove from TinyMCE
add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
}
add_action( 'init', 'disable_emojis' );
function disable_emojis_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
} else {
return array();
}
}
// remove wp version number from scripts and styles
function remove_css_js_version( $src ) {
if( strpos( $src, '?ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'remove_css_js_version', 9999 );
add_filter( 'script_loader_src', 'remove_css_js_version', 9999 );
//Disable RSS Feeds in WordPress
function fb_disable_feed() {
wp_die( __('No feed available,please visit our homepage!') );
}
add_action('do_feed', 'fb_disable_feed', 1);
add_action('do_feed_rdf', 'fb_disable_feed', 1);
add_action('do_feed_rss', 'fb_disable_feed', 1);
add_action('do_feed_rss2', 'fb_disable_feed', 1);
add_action('do_feed_atom', 'fb_disable_feed', 1);
function turn_off_feed() {
wp_die( __('Our Feed is currently off') );
}
add_action('do_feed', 'turn_off_feed', 1);
add_action('do_feed_rdf', 'turn_off_feed', 1);
add_action('do_feed_rss', 'turn_off_feed', 1);
add_action('do_feed_rss2', 'turn_off_feed', 1);
add_action('do_feed_atom', 'turn_off_feed', 1);
add_action('do_feed_rss2_comments', 'turn_off_feed', 1);
add_action('do_feed_atom_comments', 'turn_off_feed', 1);
//Disable XML-RPC in WordPress
add_filter('xmlrpc_enabled', '__return_false');
*/
/*===============================================================================================
===============================================================================================*/
// Only show products in the front-end search results
add_filter('pre_get_posts','lw_search_filter_pages');
function lw_search_filter_pages($query) {
// Frontend search only
if ( ! is_admin() && $query->is_search() ) {
$query->set('post_type', 'product');
$query->set( 'wc_query', 'product_query' );
}
return $query;
}
/*===============================================================================================
RESPONSIVE MENU
===============================================================================================*/
add_action( 'woocommerce_before_shop_loop_item_title', function(){
global $product;
$permalink = $product->get_permalink();
$user = wp_get_current_user();
if( ! empty( $user ) && in_array( "administrator", (array) $user->roles ) ) {
//El usuario actual es administrador
echo '';
}
echo do_shortcode( '[yith_wcwl_add_to_wishlist wishlist_url="'.site_url().'/wishlist/"]' );
echo '';
}, 9 );
add_filter( 'wpcf7_autop_or_not', '__return_false' );
/*===============================================================================================
RESPONSIVE MENU
===============================================================================================*/
/*
if (!session_id()) {
session_start();
}
add_action('wp_ajax_nopriv_sendCode', 'sendCode');
add_action('wp_ajax_sendCode', 'sendCode');
function sendCode($vars) {
global $wp;
global $wpdb;
require dirname( __FILE__ ).'/vendor/autoload.php';
$celular = sanitize_text_field($_POST['celular']);
if(strlen($celular) == 10){
$params = array(
'credentials' => array(
'key' => 'AKIA4647MVVUXTI52BIN',
'secret' => '2oxbAAL+olB0IWbSjKYzqu70xd/Mg3WGyvolQEi4',
),
'region' => 'us-east-1', // < your aws from SNS Topic region
'version' => 'latest'
);
$sns = new \Aws\Sns\SnsClient($params);
$codeRand = rand(1000,9999);
$_SESSION['codeRand'] = $codeRand;
$args = array(
"Message" => "¡Hola! Para seguir tu proceso de registro en Ágape digita el código ".$codeRand.". No compartas este código con terceros.",
"PhoneNumber" => "+57".$_POST['celular']
);
$result = $sns->publish($args);
//echo "",var_dump($result),"
";
$meta = $result->get('@metadata');
//var_dump($meta);
if($meta['statusCode'] === 200){
//echo "Message enviado";
echo '{"success":"ok","msg":"Mensaje enviado","data":{"phone":"+57'.$_POST['celular'].'"}}';
}else{
echo '{"success":"error","msg":"error"';
}
}else{
echo '{"success":"error","msg":"error"';
}
die();
}
*/
/*===============================================================================
VALIDAR FORMULARIO
===============================================================================*/
add_filter( 'wpcf7_validate_tel*', 'GSRG_Enrollment_Form_Validation', 20, 2 );
add_filter( 'wpcf7_validate_tel', 'GSRG_Enrollment_Form_Validation', 20, 2 );
function GSRG_Enrollment_Form_Validation( $result, $tag ) {
if( $tag->name == 'codigo' && is_numeric($_POST['codigo']) ){
if($_POST['codigo'] != $_SESSION['codeRand'] ){
$result->invalidate( $tag , "Verifica el código enviado a tu celular" );
}
}else if( $tag->name == 'celular' && !is_numeric($_POST['celular']) && strlen($_POST['celular'] != 10) ){
$result->invalidate( $tag , "Verifica tu número de celular" );
}
//$result->invalidate( $tag , "Verifica" );
return $result;
}
/*===============================================================================
GUARDAR FORMULARIO
===============================================================================*/
add_action( 'wpcf7_mail_sent', 'cspd_call_after_for_submit', 10, 1 );
function cspd_call_after_for_submit( $contact_data ){
global $wpdb,$table_prefix;
//?utm_source=facebook&utm_medium=conversiones&utm_campaign=cam
$url_components = parse_url( $_POST['utm'] );
$parse_url = parse_str($url_components['query'], $params);
$wpcf7 = WPCF7_ContactForm::get_current();
if($wpcf7->id == 8876 || $wpcf7->id == 10696 ){
//nombre email celular ciudad utm refer fecha
$wpdb->show_errors(true);
$result_check = $wpdb->insert(
$table_prefix.'representantes',
array(
'nombre' => sanitize_text_field( $_POST['nombre'] ),
'email' => sanitize_text_field( $_POST['email'] ),
'celular' => sanitize_text_field( $_POST['celular'] ),
'ciudad' => sanitize_text_field( $_POST['ciudad'] ),
'utm' => sanitize_text_field( $_POST['utm'] ),
'utm_source' => sanitize_text_field( $params['utm_source'] ),
'utm_medium' => sanitize_text_field( $params['utm_medium'] ),
'utm_campaign' => sanitize_text_field( $params['utm_campaign'] ),
'refer' => sanitize_text_field( $_POST['refer'] ),
'tiendafisica' => sanitize_text_field( $_POST['tiendafisica'] ),
)
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://plugcrm.net/api/v1/contacts?token=62ffa468fd77970015d1d40e',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"token": "62ffa468fd77970015d1d40e",
"contact": {
"name": "'.$_POST['nombre'].' ' .$_POST['apellido'].'",
"title": "'.$_POST['ciudad'].'",
"emails": [{"email": "'.$_POST['email'].'"}],
"phones": [{"phone": "'.$_POST['celular'] .'"}],
"organization_id": "Ágape",
"legal_bases": [
{
"category": "data_processing",
"type": "consent",
"status": "granted"
}
]
}
}
',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
/* if($_POST['nombre'] == "test"){
echo 111;
echo $response;
exit;
}*/
}else if($wpcf7->id == 9220 ){
$wpdb->show_errors(false);
$result_check = $wpdb->insert(
$table_prefix.'pdf',
array(
'nombre' => sanitize_text_field( $_POST['nombre'] ),
'email' => sanitize_text_field( $_POST['email'] ),
'utm' => sanitize_text_field( $_POST['utm'] ),
'utm_source' => sanitize_text_field( $params['utm_source'] ),
'utm_medium' => sanitize_text_field( $params['utm_medium'] ),
'utm_campaign' => sanitize_text_field( $params['utm_campaign'] ),
'refer' => sanitize_text_field( $_POST['refer'] ),
)
);
}
}
/*===============================================================================
CAMPOS PERSONALIZADOS
===============================================================================*/
add_action( 'wpcf7_init', 'custom_add_form_tag_type' );
function custom_add_form_tag_type() {
wpcf7_add_form_tag( 'utm', 'custom_input_utm' );
}
function custom_input_utm( $tag ) {
$html = '';
if($_SERVER){
$html = '';
$html .= '';
}
return $html;
}
/*===============================================================================
LISTADO PRODUCTOS
===============================================================================*/
add_shortcode('list_productos','list_productos_fn');
function list_productos_fn() {
global $woocommerce;
echo "=============>";
$args = array(
'posts_per_page' => -1,
'post_type' => 'product',
);
$the_query = new WP_Query( $args );
$product_min_qty = [];
if( $the_query->have_posts() ):
while( $the_query->have_posts() ) : $the_query->the_post();
//echo get_the_ID();
//echo "
";
echo ''.get_the_title().'
';
//echo wp_get_attachment_url( get_the_ID() );
echo '
';
echo "
==================================
";
endwhile;
endif;
wp_reset_query();
}
add_shortcode( "prueba", "prueba_fn" );
function prueba_fn(){
echo "prueba fn";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://200.225.218.61:9080/api/totvsmoda/authorization/v2/token',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'grant_type=password&client_id=agapeapiv2&client_secret=8483481421&username=INTEGRADO&password=789',
CURLOPT_HTTPHEADER => array(
'usuario: agapews',
'senha: 778549',
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
var_dump($response );
curl_close($curl);
echo $response;
}
Ágape Moda Católica Colombia
Página en construcción
Lamentamos las molestias