Skip to content

Instantly share code, notes, and snippets.

View agrogeek's full-sized avatar

Sebas MGC agrogeek

View GitHub Profile
@agrogeek
agrogeek / replace_url_wp.sql
Created April 7, 2020 10:22
Replace URL for WordPress DB
UPDATE wp_posts SET post_content = replace(post_content, 'http://old.url', 'http://new.url');
@agrogeek
agrogeek / anchors_headers_sticky.css
Created April 13, 2020 12:25
Hack para anchors con el header sticky
/* Hack para anchors con el header sticky */
:target::before {
content: "";
display: block;
height: 120px;
margin: -120px 0 0;
}
@agrogeek
agrogeek / plugin-machete.url
Created April 21, 2020 10:28
Plugin WP multipropósito, eficiente y sencillo
https://machetewp.com/
@agrogeek
agrogeek / admin_head_post_edit_check.php
Last active April 28, 2020 14:19 — forked from petenelson/admin_head_post_edit_check.php
WordPress admin action hooks for listing/adding/editing posts or pages
/* actions fired when listing/adding/editing posts or pages */
/* admin_head-(hookname) to head include */
/* admin_footer-(hookname) to footer include */
add_action( 'admin_head-post.php', 'admin_head_post_editing' );
add_action( 'admin_head-post-new.php', 'admin_head_post_new' );
add_action( 'admin_head-edit.php', 'admin_head_post_listing' );
function admin_head_post_editing() {
echo 'you are editing a post';
}
@agrogeek
agrogeek / exemple.php
Created April 29, 2020 14:11 — forked from willybahuaud/exemple.php
wp_dropdown_category multiple
<?php
wp_dropdown_categories( array(
'taxonomy' => 'category',
'multiple' => true,
'walker' => new Willy_Walker_CategoryDropdown(),
'selected' => array( 10, 12 ), // selected terms…
'hide_empty' => false,
) );
@agrogeek
agrogeek / Disabled panels WP editor.txt
Created April 29, 2020 14:52
Deshabilitar paneles del editor de WP desde código
// remove excerpt panel
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'post-excerpt' );
Here is an (incomplete) list of panel IDs:
taxonomy-panel-category - Category panel.
taxonomy-panel-CUSTOM-TAXONOMY-NAME - Custom taxonomy panel. If your taxonomy is topic, then taxonomy-panel-topic works.
taxonomy-panel-post_tag - Tags panel
featured-image - Featured image panel.
post-link - Permalink panel.
page-attributes - Page attributes panel.
@agrogeek
agrogeek / screenshots.php
Created May 31, 2020 12:01
Make screenshots with PHP
<?php
//index.php
$screen_shot_image = '';
if(isset($_POST["screen_shot"]))
{
$url = $_POST["url"];
$screen_shot_json_data = file_get_contents("https://www.googleapis.com/pagespeedonline/v2/runPagespeed?url=$url&screenshot=true");
@agrogeek
agrogeek / wp-cli: create block gutenberg
Created June 17, 2020 14:15
Comando de WP CLI para crear arquitectura de un bloque Gutenberg
wp scaffold block <slug-block> --title="<title-block>" --category=<category> --theme
@agrogeek
agrogeek / dequeue-invisible-recaptcha.php
Created December 16, 2020 15:28
WP HACK - dequeue script google-invisible-recaptcha plugin in front pages
add_action('wp_print_scripts', function (){
if( !in_array( $GLOBALS[ 'pagenow' ], array( 'wp-login.php', 'OTHER PAGES WITHOUT INVISIBLE RECAPTCHA' ), true ) ){
wp_dequeue_script( 'google-invisible-recaptcha' );
}
});
@agrogeek
agrogeek / functions.php
Created March 18, 2021 06:18
Optimizaciones para WordPress (jquery migrate, pingbacks, emojis)
/* Desahbilitar jquery migrate */
function montanera_remove_jquery_migrate( &$scripts ) {
if( !is_admin() ) {
$scripts->remove( 'jquery' );
$scripts->add( 'jquery', false, array( 'jquery-core' ), '1.12.4' );
}
}
add_filter( 'wp_default_scripts', 'montanera_remove_jquery_migrate' );