Snippets Collections
<?php $recent = new WP_Query("posts_per_page=-1&cat=26&orderby=title&order=ASC");
                    while ($recent->have_posts()) : $recent->the_post(); ?>
                        <div class="col-sm-5 col-md-3">
                            <div class="thumbnail" style="text-align:center;">
                                <a class="logosSocios" target="_blank" href="<?php the_field('enlace') ?>"><span><?php the_post_thumbnail('', ['class' => 'img-responsive center-block']); ?></span></a>
                                <div class="caption">
                                    <!-- <h4><?php the_title(); ?></h4> -->
                                    <a class="btn btn-primary btn-socios" style="color: white; border-color: #fff;" href="<?php the_field('enlace') ?>" target="_blank" rel="noopener noreferrer"><?php the_title(); ?></a>
                                </div>
                            </div>
                        </div>
                    <?php endwhile;
                    wp_reset_query(); ?>
<!--la ruta absoluta-->
<img src="<?php echo get_bloginfo('wpurl');?>/wp-content/themes/temacreado/img/w.logo.png" alt="">
<!--
<?php echo get_bloginfo('wpurl');?> nos da la ruta de: http://localhost/cliente/  la ruta del archivo que tiene todo el wordpress dentro.
-->   
  
<!--La ruta relativa-->
<img src="wp-content/themes/temacreado/img/w.logo.png" alt="">
<!--
solo es la ruta relativa que es segun la ubicación del archivo
pero como los dos archivos se crean con page.php solo la portada es direccionada adecuadamente con esa direción relativa. lo que las paginas(no portada)  no lo reconocen; por eso la nececidad de dar la pocición absoluta.
-->

  <!-- Nos dimos cuenta que -->
  
/* Make Elementor elements expand to fit the full available width - due to how EL puts padding
all the way round columns */
.elementor-section-boxed .elementor-column-gap-default > .elementor-row {
    width: calc(100% + 20px);
    margin-left: -10px;
    margin-right: -10px;
}
.elementor-section-boxed .elementor-column-gap-narrow > .elementor-row {
    width: calc(100% + 10px);
    margin-left: -5px;
    margin-right: -5px;
}
.elementor-section-boxed .elementor-column-gap-extended > .elementor-row {
    width: calc(100% + 30px);
    margin-left: -15px;
    margin-right: -15px;
}
.elementor-section-boxed .elementor-column-gap-wide > .elementor-row {
    width: calc(100% + 40px);
    margin-left: -20px;
    margin-right: -20px;
}
.elementor-section-boxed .elementor-column-gap-wider > .elementor-row {
    width: calc(100% + 60px);
    margin-left: -30px;
    margin-right: -30px;
}
if ( ! function_exists( 'is_shop' ) ) :
    function is_shop() {
        //your codes goes here. 
    }
endif; 
UPDATE wp_options SET option_value = replace(option_value, 'oldurl.com', 'newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'oldurl.com','newurl.com');
UPDATE wp_posts SET post_content = replace(post_content, 'oldurl.com', 'newurl.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'oldurl.com','newurl.com');
/* No-index posts older than 90 days if in PR custom post type */

function noindexOldPRs() {
	$url = 'http://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
	$current_post_id = url_to_postid( $url );
	
	$publishdate = get_the_time('Y-m-d', $current_post_id);
	$posttype = get_post_type ($current_post_id);
	
	if ($posttype == "pr") {
		$ninetydaysago = date("Y-m-d", strtotime("-90 days"));
		if($publishdate < $ninetydaysago) {
			echo '<meta name="robots" content="noindex">';
		}
	} elseif (has_tag('nonnews', $current_post_id)) {
		echo '<meta name="Googlebot-News" content="noindex, nofollow">';
	}
	
	//add noindex/nofollow for google news bot
	// get tags
	// if a tag includes nonnews
	// then add
	// <meta name="Googlebot-News" content="noindex, nofollow">

}
add_action('wp_head', 'noindexOldPRs');
.wpcf7 input,
.wpcf7 textarea,
.wpcf7 input[type="submit"] {
transition: 0.3s ease-in-out all
}

.wpcf7 input:not([type="submit"]),
.wpcf7 textarea {
width: 100%;
}

.wpcf7 input:not([type=radio]):not([type=checkbox]):not([type=submit]):not([type=button]):not([type=image]):not([type=file]),
.wpcf7 textarea {
border-width: 0 0 2px;
border-color: #41506DFF;
border-style: solid;
background-color: #FFFFFFFF;
padding: 8px;
color: #3F3F3F;
margin-bottom:20px;
}

.wpcf7 input:not([type=radio]):not([type=checkbox]):not([type=submit]):not([type=button]):not([type=image]):not([type=file]):focus,
.wpcf7 textarea:focus {
border-width: 0 0 2px;
border-color: #41506D;
border-style: none;
background-color: #FFFFFFFF;
box-shadow: 0px 0px 13px #00000024;
}
.wpcf7 label {
font-size:16px;
font-weight:600;
color:#41506D;
}
.wpcf7 input::placeholder,
.wpcf7 textarea::placeholder {
font-size:16px;
font-weight:600;
color:#000000;
}
.wpcf7 input[type="submit"] {
font-size:16px;
font-weight:600;
color:#FFFFFF;
background-color:#41506D;
padding:16px 40px;
height: auto;
display: block;
width: 100%;
max-width: 100%;
border-radius: 30px;
}
.wpcf7 input[type="submit"]:hover {
color:#FFFFFFFF;
background-color:#6A82A6FF;
box-shadow: 0px 12px 33px #00000055;
border-radius: 30px;
}
## EXPIRES HEADER CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/svg "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES HEADER CACHING ##
remove_theme_support(  'block-templates' );
// hoja css
wp_enqueue_style( 'tema_fray_framework', get_template_directory_uri().'/css/fray.css',array(),time());
// hoja Js
wp_enqueue_script( 'tema_fray_js', get_template_directory_uri() . '/js/misfunciones.js', array(),time(),true);

// true: carga el js en el footer
// false(por defecto): carga el js en el head
// Nota: "las hojas css(estilo), se deben cargar en el head(defaul o false)" 
wp search-replace '<script async\s*.*>\s*.*<\/script>' '' wp_posts --regex --allow-root
if ( ! defined( 'WPINC' ) ) {
	die;
}

add_action( 'wp_enqueue_scripts', 'custom_enqueue_files' );
/**
 * Loads <list assets here>.
 */
function custom_enqueue_files() {
	// if this is not the front page, abort.
	// if ( ! is_front_page() ) {
	// 	return;
	// }

	// loads a CSS file in the head.
	// wp_enqueue_style( 'highlightjs-css', plugin_dir_url( __FILE__ ) . 'assets/css/style.css' );

	/**
	 * loads JS files in the footer.
	 */
	// wp_enqueue_script( 'highlightjs', plugin_dir_url( __FILE__ ) . 'assets/js/highlight.pack.js', '', '9.9.0', true );

	// wp_enqueue_script( 'highlightjs-init', plugin_dir_url( __FILE__ ) . 'assets/js/highlight-init.js', '', '1.0.0', true );
}
jQuery(document).ready(function($) {
    // $() will work as an alias for jQuery() inside of this function
    [ your code goes here ]
} );
//set up load.php inside /wp-content/mu-plugins, then add:
require(WPMU_PLUGIN_DIR . '/myplugin/myplugin.php');

//OR –– use below for multiple mu-plugins inside a subdirectory
//
// Opens the must-use plugins directory
$wpmu_plugin_dir = opendir(WPMU_PLUGIN_DIR);

// Lists all the entries in this directory
while (false !== ($entry = readdir($wpmu_plugin_dir))) {
$path = WPMU_PLUGIN_DIR . '/' . $entry;

// Is the current entry a subdirectory?
if ($entry != '.' && $entry != '..' && is_dir($path)) {
// Includes the corresponding plugin
require($path . '/' . $entry . '.php');
}
}

// Closes the directory
closedir($wpmu_plugin_dir);
<?php
/**
 * Gutenberg Examples Stylesheets
 */
 
function gutenberg_examples_02_register_block() {
    wp_register_script(
        'gutenberg-examples-02',
        plugins_url( 'block.js', __FILE__ ),
        array( 'wp-blocks', 'wp-element' ),
        filemtime( plugin_dir_path( __FILE__ ) . 'block.js' )
    );
 
    wp_register_style(
        'gutenberg-examples-02-editor',
        plugins_url( 'editor.css', __FILE__ ),
        array( 'wp-edit-blocks' ),
        filemtime( plugin_dir_path( __FILE__ ) . 'editor.css' )
    );
 
    wp_register_style(
        'gutenberg-examples-02',
        plugins_url( 'style.css', __FILE__ ),
        array( ),
        filemtime( plugin_dir_path( __FILE__ ) . 'style.css' )
    );
 
    // Allow inlining small stylesheets on the frontend if possible.
    wp_style_add_data( 'gutenberg-examples-02', 'path', dirname( __FILE__ ) . '/style.css' );
 
    register_block_type( 'gutenberg-examples/example-02-stylesheets', array(
        'api_version' => 2,
        'style' => 'gutenberg-examples-02',
        'editor_style' => 'gutenberg-examples-02-editor',
        'editor_script' => 'gutenberg-examples-02',
    ) );
}
add_action( 'init', 'gutenberg_examples_02_register_block' );
$ npx @wordpress/create-block [options] [slug]
.oxygen-body{
  /* Full width styling for Oxygen Gutenberg blocks and Gutenberg images*/
  width:100vw;
  overflow-x:hidden;
}

.alignfull {
    margin-left  : calc( -100vw / 2 + 100% / 2 );
    margin-right : calc( -100vw / 2 + 100% / 2 );
    max-width    : 100vw;
}
//disable post revisions
//define('WP_POST_REVISIONS', false );

//limit post revisions
define('WP_POST_REVISIONS', 3);

//enable debug log
//define( 'WP_DEBUG_LOG', true );

//output debug log
//define( 'WP_DEBUG_DISPLAY', true );
// Place in wp-config
// removing the edit_themes, edit_plugins, and edit_files capabilities for all users
define('DISALLOW_FILE_EDIT', true);

// disable theme updates and new plugins 
// define('DISALLOW_FILE_MODS', true);
<?php

/**
 * Add required plugins to WDS_Required_Plugins.
 *
 * @param  array $required Array of required plugins in `plugin_dir/plugin_file.php` form.
 *
 * @return array           Modified array of required plugins.
 */
function wds_required_plugins_add( $required ) {

	$required = array_merge( $required, array(
		'jetpack/jetpack.php',
		'sample-plugin/sample-plugin.php',
	) );

	return $required;
}
add_filter( 'wds_required_plugins', 'wds_required_plugins_add' );

// for network activated plugins
// add_filter( 'wds_network_required_plugins', 'wds_required_plugins_add' );


/**
 * Modify the required-plugin label.
 *
 * @param  string  $label Label markup.
 *
 * @return string         (modified) label markup.
 */
function change_wds_required_plugins_text( $label ) {

	$label_text = __( 'Required Plugin for ACME', 'acme-prefix' );
	$label = sprintf( '<span style="color: #888">%s</span>', $label_text );

	return $label;
}
add_filter( 'wds_required_plugins_text', 'change_wds_required_plugins_text' );

// To hide required plugins
// add_filter( 'wds_required_plugins_remove_from_list', '__return_true' );

// Add custom dashboard logo
add_action('admin_head', 'my_custom_logo');
  
function my_custom_logo() {
echo '
<style type="text/css">
#header-logo { background-image: url('.get_bloginfo('template_directory').'/img/logo.jpg) !important; }
</style>
';
}
/*
 * Function for post duplication. Dups appear as drafts. User is redirected to the edit screen
 */
function rd_duplicate_post_as_draft(){
  global $wpdb;
  if (! ( isset( $_GET['post']) || isset( $_POST['post'])  || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
    wp_die('No post to duplicate has been supplied!');
  }
 
  /*
   * Nonce verification
   */
  if ( !isset( $GET['duplicate_nonce'] ) || !wp_verify_nonce( $_GET['duplicate_nonce'], basename( __FILE_ ) ) )
    return;
 
  /*
   * get the original post id
   */
  $post_id = (isset($_GET['post']) ? absint( $_GET['post'] ) : absint( $_POST['post'] ) );
  /*
   * and all the original post data then
   */
  $post = get_post( $post_id );
 
  /*
   * if you don't want current user to be the new post author,
   * then change next couple of lines to this: $new_post_author = $post->post_author;
   */
  $current_user = wp_get_current_user();
  $new_post_author = $current_user->ID;
 
  /*
   * if post data exists, create the post duplicate
   */
  if (isset( $post ) && $post != null) {
 
    /*
     * new post data array
     */
    $args = array(
      'comment_status' => $post->comment_status,
      'ping_status'    => $post->ping_status,
      'post_author'    => $new_post_author,
      'post_content'   => $post->post_content,
      'post_excerpt'   => $post->post_excerpt,
      'post_name'      => $post->post_name,
      'post_parent'    => $post->post_parent,
      'post_password'  => $post->post_password,
      'post_status'    => 'draft',
      'post_title'     => $post->post_title,
      'post_type'      => $post->post_type,
      'to_ping'        => $post->to_ping,
      'menu_order'     => $post->menu_order
    );
 
    /*
     * insert the post by wp_insert_post() function
     */
    $new_post_id = wp_insert_post( $args );
 
    /*
     * get all current post terms ad set them to the new post draft
     */
    $taxonomies = get_object_taxonomies($post->post_type); // returns array of taxonomy names for post type, ex array("category", "post_tag");
    foreach ($taxonomies as $taxonomy) {
      $post_terms = wp_get_object_terms($post_id, $taxonomy, array('fields' => 'slugs'));
      wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false);
    }
 
    /*
     * duplicate all post meta just in two SQL queries
     */
    $post_meta_infos = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->postmeta WHERE post_id=$post_id");
    if (count($post_meta_infos)!=0) {
      $sql_query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) ";
      foreach ($post_meta_infos as $meta_info) {
        $meta_key = $meta_info->meta_key;
        if( $meta_key == '_wp_old_slug' ) continue;
        $meta_value = addslashes($meta_info->meta_value);
        $sql_query_sel[]= "SELECT $new_post_id, '$meta_key', '$meta_value'";
      }
      $sql_query.= implode(" UNION ALL ", $sql_query_sel);
      $wpdb->query($sql_query);
    }
 
 
    /*
     * finally, redirect to the edit post screen for the new draft
     */
    wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_post_id ) );
    exit;
  } else {
    wp_die('Post creation failed, could not find original post: ' . $post_id);
  }
}
add_action( 'admin_action_rd_duplicate_post_as_draft', 'rd_duplicate_post_as_draft' );
 
/*
 * Add the duplicate link to action list for post_row_actions
 */
function rd_duplicate_post_link( $actions, $post ) {
  if (current_user_can('edit_posts')) {
    $actions['duplicate'] = '<a href="' . wp_nonce_url('admin.php?action=rd_duplicate_post_as_draft&post=' . $post->ID, basename(_FILE_), 'duplicate_nonce' ) . '" title="שכפל דף/פוסט זה" rel="permalink">שכפל דף/פוסט</a>';
  }
  return $actions;
}
 
add_filter( 'post_row_actions', 'rd_duplicate_post_link', 10, 2 );

add_filter('page_row_actions', 'rd_duplicate_post_link', 10, 2);
/*** Adds SKUs and product images to WooCommerce order emails */ 
function sww_add_sku_to_wc_emails( $args ) { $args['show_sku'] = true; return $args; } add_filter( 'woocommerce_email_order_items_args', 'sww_add_sku_to_wc_emails' );
/*** Adds product images to WooCommerce order emails */
function sww_add_photos_to_wc_emails( $args ) { $args['show_image'] = true; return $args; } add_filter( 'woocommerce_email_order_items_args', 'sww_add_photos_to_wc_emails' );
function overrule_webhook_disable_limit( $number ) {

    return 999999999999; //very high number hopefully you'll never reach.

}

add_filter( 'woocommerce_max_webhook_delivery_failures', 'overrule_webhook_disable_limit' );
add_filter( 'auto_core_update_send_email', 'wpb_stop_auto_update_emails', 10, 4 );
 
function wpb_stop_update_emails( $send, $type, $core_update, $result ) {
if ( ! empty( $type ) && $type == 'success' ) {
return false;
}
return true;
}
/* DISABLE GUTENBERG EDITOR */
// disable for posts
add_filter('use_block_editor_for_post', '__return_false');

// disable for post types
add_filter('use_block_editor_for_post_type', '__return_false');

/* END DISABLE GUTENBERG EDITOR */ 
# There are a few ways to change the url in wordpress


# The prefered method is the wp-cli via search-replace.
$ wp search-replace 'http://example.test' 'http://example.com' --skip-columns=guid

# You can also test with a dry run
$ wp search-replace 'foo' 'bar' wp_posts wp_postmeta wp_terms --dry-run


# If the wp-cli is not available or you can't use SSH there are three other ways to try inside the files wp-config and functions.php

# At the beginning of wp-config.php, add
define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );

# At the end of the file, before the comment to stop editing here, you can set the relocate method. This always takes the current url calling "/wp-login.php" as slug as site url.
define('RELOCATE',true);

# Inside funcions.php, as first call, you can set
update_option( 'siteurl', 'http://example.com');
update_option( 'home', 'http://example.com');

# Use Plugin

The plugin 'Better search replace' is also able to change the links in the database quite easily.


# As last resort, you can change the database values manually.You will have to look for "siteurl" in the table "wp_options" and change the values to the correct url.

# After changing the url, don't forget to remove the above settings again. Move to your settings in the backend and check the url. Also, inside the options section, look for "permalinks". It will bring you to an options page where you can regenerate the dynamic links. Without this regenerating, links for assets, media files and so an would possibly keep pointing to the old url. 
#!/bin/sh

### SSH Info ###
SUSER="serverusername";
SHOST="example.com";
SDIR="/srv/www/example.com";

echo 'starting rsync'

rsync -e "/usr/bin/ssh" --compress --stats -rlDHS $SUSER@$SHOST:$SDIR /srv/www/example.com

WPDBHOST=`cat /srv/www/example.com/wp-config.php | grep DB_HOST | cut -d \' -f 4`;
WPDBNAME=`cat /srv/www/tomjn.com/wp-config.php | grep DB_NAME | cut -d \' -f 4`;
WPDBUSER=`cat /srv/www/tomjn.com/wp-config.php | grep DB_USER | cut -d \' -f 4`;
WPDBPASS=`cat /srv/www/tomjn.com/wp-config.php | grep DB_PASSWORD | cut -d \' -f 4`;

echo 'finished rsync, grabbing database'

FILE=$SDIR/mysql-$WPDBNAME.sql.gz;        # Set the backup filename

#echo "mysqldump -q -u $WPDBUSER -h $WPDBHOST -p$WPDBPASS $WPDBNAME | gzip -9 > $FILE";
ssh $SUSER@$SHOST "mysqldump -q -u $WPDBUSER -h $WPDBHOST -p$WPDBPASS $WPDBNAME | gzip -9 > backup.sql.gz"

scp $SUSER@$SHOST:./backup.sql.gz .              # copy all the files to backup server
ssh $SUSER@$SHOST rm ./backup.sql.gz             # delete files on db server

gunzip -d backup.sql.gz

mysql -u root -e "CREATE DATABASE IF NOT EXISTS $WPDBNAME"
mysql -u root -e "GRANT ALL PRIVILEGES ON $WPDBNAME.* To 'wp'@'localhost'"
mysql -u wp -pwp $WPDBNAME < backup.sql

sed -i "/DB_HOST/s/'[^']*'/'localhost'/2" wp-config.php
sed -i "/DB_USER/s/'[^']*'/'wp'/2" wp-config.php
sed -i "/DB_PASSWORD/s/'[^']*'/'wp'/2" wp-config.php
WPDBNAME=`cat wp-config.php | grep DB_NAME | cut -d \' -f 4`
WPDBUSER=`cat wp-config.php | grep DB_USER | cut -d \' -f 4`
WPDBPASS=`cat wp-config.php | grep DB_PASSWORD | cut -d \' -f 4`
// Exclude certain pages from WordPress search results
//======================================
function jp_search_filter( $query ) {
  if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) {
    $query->set( 'post__not_in', array( 827,851 ) );
  }
}
add_action( 'pre_get_posts', 'jp_search_filter' );
//add allowable file types to wordpress media uploader
function custom_mime_types( $mimes ){
	$mimes['vcf'] = 'text/vcard'; //allowing .cvf filetypes
//additional filetypes can go here
	return $mimes;
}
add_filter( 'upload_mimes', 'custom_mime_types' );
add_action( 'woocommerce_after_add_to_cart_quantity', 'ts_quantity_plus_sign' );

function ts_quantity_plus_sign() {
echo '<button type="button" class="plus" >+</button>';
}

add_action( 'woocommerce_before_add_to_cart_quantity', 'ts_quantity_minus_sign' );

function ts_quantity_minus_sign() {
echo '<button type="button" class="minus" >-</button>';
}

add_action( 'wp_footer', 'ts_quantity_plus_minus' );

function ts_quantity_plus_minus() {
// To run this on the single product page
if ( ! is_product() ) return;
?>
<script type="text/javascript">

jQuery(document).ready(function($){

$('form.cart').on( 'click', 'button.plus, button.minus', function() {

// Get current quantity values
var qty = $( this ).closest( 'form.cart' ).find( '.qty' );
var val = parseFloat(qty.val());
var max = parseFloat(qty.attr( 'max' ));
var min = parseFloat(qty.attr( 'min' ));
var step = parseFloat(qty.attr( 'step' ));

// Change the value if plus or minus
if ( $( this ).is( '.plus' ) ) {
if ( max && ( max <= val ) ) {
qty.val( max );
}
else {
qty.val( val + step );
}
}
else {
if ( min && ( min >= val ) ) {
qty.val( min );
}
else if ( val > 1 ) {
qty.val( val - step );
}
}

});

});

</script>
<?php
}
// remove wp version number from head and rss
function artisansweb_remove_version() {
    return '';
}
add_filter('the_generator', 'artisansweb_remove_version');
// 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 );
//*****---   Remove Gutenberg Block Library CSS from loading on the frontend  ---*****
//===================================================================
function smartwp_remove_wp_block_library_css(){
 wp_dequeue_style( 'wp-block-library' );
 wp_dequeue_style( 'wp-block-library-theme' );
}
add_action( 'wp_enqueue_scripts', 'smartwp_remove_wp_block_library_css' );
//*****---  Remove Eicons:  ---*****
//==========================
add_action( 'wp_enqueue_scripts', 'remove_default_stylesheet', 20 ); 
function remove_default_stylesheet() { 
	wp_deregister_style( 'elementor-icons' ); 
}
//******--- Remove Font Awesome ---*****
//===============================
add_action( 'elementor/frontend/after_register_styles',function() {
	foreach( [ 'solid', 'regular', 'brands' ] as $style ) {
		wp_deregister_style( 'elementor-icons-fa-' . $style );
	}
}, 20 );
******--- Remove Google Fonts ---******
//===============================
add_filter( 'elementor/frontend/print_google_fonts', '__return_false' );
/***** Allow SVG *****/
//===================
add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {

  global $wp_version;
  if ( $wp_version !== '4.7.1' ) {
     return $data;
  }

  $filetype = wp_check_filetype( $filename, $mimes );

  return [
      'ext'             => $filetype['ext'],
      'type'            => $filetype['type'],
      'proper_filename' => $data['proper_filename']
  ];

}, 10, 4 );

function cc_mime_types( $mimes ){
  $mimes['svg'] = 'image/svg+xml';
  return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );

function fix_svg() {
  echo '<style type="text/css">
        .attachment-266x266, .thumbnail img {
             width: 100% !important;
             height: auto !important;
        }
        </style>';
}
add_action( 'admin_head', 'fix_svg' );
/***** Shorten Post/Page link  *****/
//============================
add_filter( 'get_shortlink', function ( $shortlink ) {
    return $shortlink;
});
// disable gutenberg  for posts
//========================
add_filter('use_block_editor_for_post', '__return_false', 10);

// disable gutenberg  for post types
//===========================
add_filter('use_block_editor_for_post_type', '__return_false', 10);
// Set WooCommerce Virtual Order Status to Complete After Payment
add_filter( 'woocommerce_payment_complete_order_status', 'virtual_order_payment_complete_order_status', 10, 2 );
function virtual_order_payment_complete_order_status( $order_status, $order_id ) {
  $order = new WC_Order( $order_id );
  if ( 'processing' == $order_status &&
       ( 'on-hold' == $order->status || 'pending' == $order->status || 'failed' == $order->status ) ) {
    $virtual_order = null;
    if ( count( $order->get_items() ) > 0 ) {
      foreach( $order->get_items() as $item ) {
        if ( 'line_item' == $item['type'] ) {
          $_product = $order->get_product_from_item( $item );
          if ( ! $_product->is_virtual() ) {
            // once we've found one non-virtual product we know we're done, break out of the loop
            $virtual_order = false;
            break;
          } else {
            $virtual_order = true;
          }
        }
      }
    }
    // virtual order, mark as completed
    if ( $virtual_order ) {
      return 'completed';
    }
  }
  // non-virtual order, return original status
  return $order_status;
}
add_filter( 'woocommerce_default_address_fields' , 'custom_override_postcode_validation' );
 
function custom_override_postcode_validation( $address_fields ) {
  $address_fields['postcode']['required'] = false;
  return $address_fields;
}
function search_by_sku( $search, &$query_vars ) {
    global $wpdb;
    if(isset($query_vars->query['s']) && !empty($query_vars->query['s'])){
        $args = array(
            'posts_per_page'  => -1,
            'post_type'       => 'product',
            'meta_query' => array(
                array(
                    'key' => '_sku',
                    'value' => $query_vars->query['s'],
                    'compare' => 'LIKE'
                )
            )
        );
        $posts = get_posts($args);
        if(empty($posts)) return $search;
        $get_post_ids = array();
        foreach($posts as $post){
            $get_post_ids[] = $post->ID;
        }
        if(sizeof( $get_post_ids ) > 0 ) {
                $search = str_replace( 'AND (((', "AND ((({$wpdb->posts}.ID IN (" . implode( ',', $get_post_ids ) . ")) OR (", $search);
        }
    }
    return $search;
    
}
    add_filter( 'posts_search', 'search_by_sku', 999, 2 );
add_filter( 'woocommerce_default_address_fields' , 'QuadLayers_optional_postcode_checkout' );
function QuadLayers_optional_postcode_checkout( $p_fields ) {
$p_fields['postcode']['required'] = false;
return $p_fields;
}
// Disable support for comments and trackbacks in post types
function sv_disable_comments_post_types_support() {
	$post_types = get_post_types();
	foreach ($post_types as $post_type) {
		if(post_type_supports($post_type, 'comments')) {
			remove_post_type_support($post_type, 'comments');
			remove_post_type_support($post_type, 'trackbacks');
		}
	}
}
add_action('admin_init', 'sv_disable_comments_post_types_support');



// Close comments on the front-end
function sv_disable_comments_status() {
	return false;
}
add_filter('comments_open', 'sv_disable_comments_status', 20, 2);
add_filter('pings_open', 'sv_disable_comments_status', 20, 2);



// Hide existing comments
function sv_disable_comments_hide_existing_comments($comments) {
	$comments = array();
	return $comments;
}
add_filter('comments_array', 'sv_disable_comments_hide_existing_comments', 10, 2);



// Remove comments page in menu
function sv_disable_comments_admin_menu() {
	remove_menu_page('edit-comments.php');
}
add_action('admin_menu', 'sv_disable_comments_admin_menu');



// Redirect any user trying to access comments page
function sv_disable_comments_admin_menu_redirect() {
	global $pagenow;
	if ($pagenow === 'edit-comments.php') {
		wp_redirect(admin_url()); exit;
	}
}
add_action('admin_init', 'sv_disable_comments_admin_menu_redirect');



// Remove comments metabox from dashboard
function sv_disable_comments_dashboard() {
	remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal');
}
add_action('admin_init', 'sv_disable_comments_dashboard');



// Remove comments links from admin bar
function sv_disable_comments_admin_bar() {
	if (is_admin_bar_showing()) {
		remove_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60);
	}
}
add_action('init', 'sv_disable_comments_admin_bar');
// Automatically set the image Title, Alt-Text, Caption & Description upon upload
add_action( 'add_attachment', 'my_set_image_meta_upon_image_upload' );
function my_set_image_meta_upon_image_upload( $post_ID ) {
 
    // Check if uploaded file is an image, else do nothing
 
    if ( wp_attachment_is_image( $post_ID ) ) {
 
        $my_image_title = get_post( $post_ID )->post_title;
 
        // Sanitize the title:  remove hyphens, underscores & extra spaces:
        $my_image_title = preg_replace( '%\s*[-_\s]+\s*%', ' ',  $my_image_title );
 
        // Sanitize the title:  capitalize first letter of every word (other letters lower case):
        $my_image_title = ucwords( strtolower( $my_image_title ) );
 
        // Create an array with the image meta (Title, Caption, Description) to be updated
        // Note:  comment out the Excerpt/Caption or Content/Description lines if not needed
        $my_image_meta = array(
            'ID'        => $post_ID,            // Specify the image (ID) to be updated
            'post_title'    => $my_image_title,     // Set image Title to sanitized title
            'post_excerpt'  => $my_image_title,     // Set image Caption (Excerpt) to sanitized title
            'post_content'  => $my_image_title,     // Set image Description (Content) to sanitized title
        );
 
        // Set the image Alt-Text
        update_post_meta( $post_ID, '_wp_attachment_image_alt', $my_image_title );
 
        // Set the image meta (e.g. Title, Excerpt, Content)
        wp_update_post( $my_image_meta );
 
    } 
}
add_action( 'wp_body_open', 'wpdoc_add_custom_body_open_code' );
 
function wpdoc_add_custom_body_open_code() {
    echo '<!-- Google Tag Manager (noscript) --> ... <!-- End Google Tag Manager (noscript) -->';
}
server {
  ...
    location /wp {
        alias /home/user/www/.../wordpress/;
        index index.php index.html index.htm;
        try_files $uri $uri/ /wp/index.php?$is_args$args;
    }
    location ~ \.php$ {
        root /home/user/www/.../wordpress/;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_split_path_info ^/wp(/.+\.php)(.*)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

  ...
}
//This code prevents noreferrer from being added to new or updated posts
function im_targeted_link_rel($rel_values) {
return 'noopener';
}
add_filter('wp_targeted_link_rel', 'im_targeted_link_rel',999);
//add aria label to link that opens in new tab
function aria_formatter($content) {
$replace = array('target="_blank"' => 'target="_blank" aria-label="Opens in a new tab."');
$new_content = strtr($content, $replace);
return $new_content;
}
add_filter('the_content', 'aria_formatter', 999);
<script>
jQuery( document ).ready(function($){
	$(document).on('click','.elementor-location-popup a', function(event){
		elementorProFrontend.modules.popup.closePopup( {}, event);
	})
});
</script>
The 'tax_query' clauses can be nested, to create more complex queries. Example: Display posts that are in the quotes category OR both have the quote post format AND are in the wisdom category:

$args = array(
	'post_type' => 'post',
	'tax_query' => array(
		'relation' => 'OR',
		array(
			'taxonomy' => 'category',
			'field'    => 'slug',
			'terms'    => array( 'quotes' ),
		),
		array(
                        'relation' => 'AND',
                        array(
			        'taxonomy' => 'post_format',
			        'field'    => 'slug',
			        'terms'    => array( 'post-format-quote' ),
                        ),
                        array(
                                'taxonomy' => 'category',
                                'field'    => 'slug',
                                'terms'    => array( 'wisdom' ),
                        ),
		),
	),
);
$query = new WP_Query( $args );

Display posts from several custom taxonomies:

$args = array(
	'post_type' => 'post',
	'tax_query' => array(
		'relation' => 'AND',
		array(
			'taxonomy' => 'movie_genre',
			'field'    => 'slug',
			'terms'    => array( 'action', 'comedy' ),
		),
		array(
			'taxonomy' => 'actor',
			'field'    => 'term_id',
			'terms'    => array( 103, 115, 206 ),
			'operator' => 'NOT IN',
		),
	),
);
$query = new WP_Query( $args );
Simple Taxonomy Query:

Display posts tagged with bob, under people custom taxonomy:

$args = array(
	'post_type' => 'post',
	'tax_query' => array(
		array(
			'taxonomy' => 'people',
			'field'    => 'slug',
			'terms'    => 'bob',
		),
	),
);
$query = new WP_Query( $args );
<?php

add_action('wp_enqueue_scripts', 'my_theme_enqueue_styles');

function my_theme_enqueue_styles()
{
    wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
    wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style'));
    wp_enqueue_script('custom-script', get_stylesheet_directory_uri() . '/path/to/script.js', '', '', true );
}
[trp_language language="en_US"]

 //Add custom HTML for the English here

[/trp_language]

[trp_language language="fr_FR"]

 //Add custom HTML for the French here

[/trp_language]
star

Thu Dec 23 2021 14:51:05 GMT+0000 (UTC)

#wordpress #loopw
star

Wed Dec 22 2021 23:16:29 GMT+0000 (UTC) https://es.stackoverflow.com/questions/505679/para-los-que-conocen-wordpress-y-creadores-de-temas/505704#505704

#wordpress #html #php
star

Wed Dec 22 2021 21:29:14 GMT+0000 (UTC) https://snipsave.com/user/richflynn/snippet/CKoeXWGzyW91z9xEma/

#elementor #wordpress
star

Fri Dec 17 2021 17:46:27 GMT+0000 (UTC) https://make.wordpress.org/themes/2021/12/15/reminder-if-your-theme-integrates-with-external-plugins-make-sure-that-they-are-available-before-trying-to-use-them/

#php #wordpress
star

Thu Dec 09 2021 11:10:27 GMT+0000 (UTC)

#mysql #wordpress
star

Wed Dec 01 2021 00:27:48 GMT+0000 (UTC) https://formstyler.com/

#css #contact #cf7 #wordpress
star

Mon Nov 22 2021 19:22:51 GMT+0000 (UTC) https://kinsta.com/nl/kennisbank/voeg-expires-headers-wordpress/

#wordpress #htaccess
star

Thu Nov 18 2021 03:18:48 GMT+0000 (UTC)

#wordpress #php #gutenberg
star

Wed Nov 17 2021 17:57:20 GMT+0000 (UTC) https://desarrollowp.com/blog/tutoriales/mover-los-scripts-al-footer-wordpress/

#javascript #css #wordpress
star

Mon Oct 25 2021 06:55:32 GMT+0000 (UTC) https://github.com/srikat/my-custom-functionality/blob/master/plugin.php

#wordpress #mu-plugins #php
star

Mon Oct 25 2021 06:48:12 GMT+0000 (UTC) https://developer.wordpress.org/reference/functions/wp_enqueue_script/

#wordpress #mu-plugins #jquery
star

Mon Oct 25 2021 06:36:11 GMT+0000 (UTC) https://www.sitepoint.com/wordpress-mu-plugins/

#wordpress #php #mu-plugins
star

Mon Oct 25 2021 05:31:55 GMT+0000 (UTC) https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/applying-styles-with-stylesheets/

#wordpress #gutenberg #styles
star

Mon Oct 25 2021 05:16:11 GMT+0000 (UTC) https://www.npmjs.com/package/@wordpress/create-block

#wordpress #gutenberg #git #npm
star

Mon Oct 25 2021 04:49:03 GMT+0000 (UTC) https://www.wordstamped.com/1022/full-width-oxygen-block/

#wordpress #oxygen #css #gutenberg
star

Mon Oct 25 2021 04:21:40 GMT+0000 (UTC)

#wordpress #php #wp-config
star

Mon Oct 25 2021 04:15:43 GMT+0000 (UTC)

#wordpress #php #wp-config
star

Mon Oct 25 2021 03:40:24 GMT+0000 (UTC) https://github.com/WebDevStudios/WDS-Required-Plugins

#wordpress #php #plugin
star

Fri Oct 22 2021 16:30:17 GMT+0000 (UTC) https://developer.wordpress.org/reference/functions/add_action/

#php #wordpress #functions #documentation #prority
star

Thu Jul 22 2021 21:24:54 GMT+0000 (UTC)

#php #wordpress
star

Thu Jul 22 2021 21:23:10 GMT+0000 (UTC)

#php #wordpress
star

Mon Jul 05 2021 16:02:04 GMT+0000 (UTC)

#webhook #wordpress
star

Thu Jul 01 2021 10:52:22 GMT+0000 (UTC) https://www.wpbeginner.com/wp-tutorials/how-to-disable-automatic-update-email-notification-in-wordpress/

#wordpress
star

Fri Jun 11 2021 14:15:50 GMT+0000 (UTC) https://developer.wordpress.org/cli/commands/search-replace/, https://wordpress.org/support/article/changing-the-site-url/

#wordpress #configuration #url #network
star

Mon Jun 07 2021 18:14:17 GMT+0000 (UTC) https://tomjn.com/2014/03/01/wordpress-bash-magic/

#wordpress #automate #provision #vagrant #vm
star

Mon Jun 07 2021 18:06:54 GMT+0000 (UTC) https://stackoverflow.com/questions/7586995/read-variables-from-wp-config-php

#wordpress #database #credentials #automate
star

Wed May 26 2021 10:14:35 GMT+0000 (UTC) https://www.johnparris.com/exclude-certain-pages-from-wordpress-search-results/

#php #wordpress
star

Thu May 13 2021 21:59:34 GMT+0000 (UTC) https://www.clevelandwebdeveloper.com/code-snippets/wordpress-add-allowed-file-types/

#php #wordpress
star

Thu May 13 2021 15:05:08 GMT+0000 (UTC) https://www.tychesoftwares.com/how-to-add-plus-and-minus-buttons-to-the-quantity-input-on-the-product-page-in-woocommerce/

#php #wordpress
star

Wed May 12 2021 22:38:25 GMT+0000 (UTC)

#php #wordpress
star

Wed May 12 2021 22:37:16 GMT+0000 (UTC)

#php #wordpress #elementor
star

Fri May 07 2021 18:34:56 GMT+0000 (UTC)

#php #wordpress
star

Fri May 07 2021 18:34:23 GMT+0000 (UTC)

#php #wordpress
star

Fri May 07 2021 18:33:50 GMT+0000 (UTC)

#php #wordpress
star

Fri May 07 2021 18:25:16 GMT+0000 (UTC)

#php #wordpress #woocomerce
star

Fri May 07 2021 18:21:47 GMT+0000 (UTC)

#php #wordpress
star

Fri May 07 2021 18:15:24 GMT+0000 (UTC) https://wpdev.co.il/%d7%94%d7%92%d7%93%d7%a8%d7%94-%d7%90%d7%95%d7%98%d7%95%d7%9e%d7%98%d7%99%d7%aa-%d7%a9%d7%9c-%d7%9b%d7%95%d7%aa%d7%a8%d7%aa-alt-%d7%9b%d7%99%d7%aa%d7%95%d7%91-%d7%95%d7%aa%d7%99%d7%90%d7%95%d7%a8/

#php #wordpress
star

Sat Mar 06 2021 03:42:11 GMT+0000 (UTC) https://rckflr.com

#wordpress #google #tag #manager #function
star

Thu Oct 01 2020 20:31:22 GMT+0000 (UTC) http://man.hubwiz.com/docset/WordPress.docset/Contents/Resources/Documents/codex.wordpress.org/Function_Reference/WP_Query.html

#wordpress #query #taxonomie
star

Thu Oct 01 2020 20:30:16 GMT+0000 (UTC) http://man.hubwiz.com/docset/WordPress.docset/Contents/Resources/Documents/codex.wordpress.org/Function_Reference/WP_Query.html

#wordpress #query #taxonomie
star

Thu Oct 01 2020 20:29:15 GMT+0000 (UTC) http://man.hubwiz.com/docset/WordPress.docset/Contents/Resources/Documents/codex.wordpress.org/Function_Reference/WP_Query.html

#wordpress #query #taxonomie
star

Wed Aug 26 2020 16:08:48 GMT+0000 (UTC)

#php #wordpress

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension