View form-login-WordPress.php
<?php // No copiar esta línea | |
function dcms_form_login_config() { | |
$redirect_login = get_home_url(); | |
$redirect_logout = get_home_url(); | |
if ( ! is_user_logged_in() ): | |
$args = array( | |
'echo' => false, | |
'redirect' => $redirect_login, |
View Search-in-table-HTML.js
/* | |
Se requiere pasar un objeto vars_table, que contenga el selector de la tabla HTML y el placeholder, por ejemplo: | |
let vars_table = { | |
"select": "table.table-data", | |
"placeholder": "Buscar empleados" | |
} | |
*/ | |
(function( $ ) { |
View leer-base-datos-externa.php
<? // no copiar esta línea | |
add_filter( 'the_content', 'dcms_list_data' ); | |
function dcms_list_data( $content ) { | |
$database_name = 'employees'; // nombre de la base de datos | |
$database_user = 'root'; | |
$database_pass = 'root'; | |
$database_server = 'localhost'; |
View one-page-wordpress-script.js
(function( $ ) { | |
const marginTop = 170; // puedes cambiar el margen | |
const currentClasses = 'current-menu-item current_page_item'; | |
if ( ! window.location.hash ){ | |
$('li').removeClass(currentClasses); | |
$('li:first-child').addClass(currentClasses); | |
} | |
$('li a[href*="#"]').click(function(event) { |
View cambiar-precio-producto.php
<?php // No copiar esta línea | |
// Para el detalle de producto, creación de controlo y cambio de precio | |
add_action('woocommerce_before_add_to_cart_button', 'dcms_build_select_field'); | |
function dcms_build_select_field(){ | |
global $product; | |
$options = [ |
View ejemplo-cache-objetos-WordPress.php
<?php // no copiar esta línea | |
add_filter('the_content', 'dcms_related_content'); | |
function dcms_related_content( $content ){ | |
if ( ! is_single() ) return $content; | |
$post_id = get_the_ID(); |
View custom-loop-woocommerce.php
<?php | |
if( ! function_exists('wc_get_products') ) return; | |
// definimos las variables de paginación y filtro | |
$paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1; | |
$ordering = WC()->query->get_catalog_ordering_args(); | |
$ordering['orderby'] = array_shift(explode(' ', $ordering['orderby'])); | |
$ordering['orderby'] = stristr($ordering['orderby'], 'price') ? 'meta_value_num' : $ordering['orderby']; | |
$products_per_page = apply_filters('loop_shop_per_page', wc_get_default_products_per_row() * wc_get_default_product_rows_per_page()); |
View insertar-subtitulo-wordpress.php
<?php // Esta línea no se debe copiar | |
add_action( 'wp_print_footer_scripts', function () { | |
if (is_singular()): | |
$subtitulo = get_post_meta(get_the_ID(), 'Subtitulo', true); | |
if ( $subtitulo ): | |
?> | |
<script> | |
(function( $ ) { | |
let str = '<span class="dcms-subtitle">'; |
View get-data-custom-table-wordpress.php
<?php //obviar este línea | |
add_filter( 'the_content', 'dcms_list_data' ); | |
function dcms_list_data( $content ) { | |
$slug_page = 'frutas'; //slug de la página en donde se mostrará la tabla | |
$table_name = 'data_fruit'; // nombre de la tabla | |
if (is_page($slug_page)){ | |
global $wpdb; |
NewerOlder