Skip to content

Instantly share code, notes, and snippets.

View agrogeek's full-sized avatar

Sebas MGC agrogeek

View GitHub Profile
@agrogeek
agrogeek / composer-view.js
Created August 7, 2019 07:57
Fix Elementor edit panel error
/**
* Convert html into correct element
* @param html
*/
html2element:function(html) {
var $template, attributes = {},
template = html;
$template = $(template(this.model.toJSON()).trim()), _.each($template.get(0).attributes, function(attr) {
attributes[attr.name] = attr.value
}), this.$el.attr(attributes).html($template.html()), this.setContent(), this.renderContent()
@agrogeek
agrogeek / wp_add_fa_classes_menu_social_links.php
Last active January 20, 2020 08:43
nav_menu_css_class filter to add classes to the social links of the menu
body.login {}
body.login div#login {}
body.login div#login h1 {}
body.login div#login h1 a {}
body.login div#login form#loginform {}
body.login div#login form#loginform p {}
body.login div#login form#loginform p label {}
body.login div#login form#loginform input {}
body.login div#login form#loginform input#user_login {}
body.login div#login form#loginform input#user_pass {}
@agrogeek
agrogeek / wp_multisite_shortcode_list_sites.php
Created January 22, 2020 14:46
Add shortcode to list sites in WP Multisite
function make_list_shortcode() {
$subsites = get_sites(array('orderby' => 'registered', 'order' => 'DESC' ));
if ( ! empty ( $subsites ) ) {
$html = '<ul class="subsites">';
foreach( $subsites as $subsite ) {
@agrogeek
agrogeek / wp_shortcode_print_menu.php
Created January 23, 2020 08:31
Add a menu using shortcode. Usage: [print-menu name = "menu-name" class = "class1 class2"]. Defaults: name='primary', class=''.
<?php
function syltec_print_custom_menu_shortcode($atts)
{
// Normalize
$atts = array_change_key_case((array)$atts, CASE_LOWER);
$atts = array_map('sanitize_text_field', $atts);
// Attributes
$menu_name = isset($atts['name'])?$atts['name']:'primary';
$menu_class = isset($atts['class'])?$atts['class']:'';
return wp_nav_menu(array(
@agrogeek
agrogeek / config
Created January 31, 2020 08:14
Para añadir un origen remoto (GitHub) a un repositorio ya creado en local en Atom. Editamos .git/config y añadimos:
[remote "origin"]
url = "https://github.com/user/repository"
@agrogeek
agrogeek / Comando.cmd
Created February 8, 2020 18:22
Extraer clave producto de Windows 10
/* comando en Símbolo de Sistema */
wmic path softwarelicensingservice get OA3xOriginalProductKey
@agrogeek
agrogeek / preventdefault.js
Last active February 10, 2020 15:51
Prevent click en enlaces con JavaScript puro
/* Esperamos a que cargue la página */
window.onload = function() {
/* Seleccionamos por target, class, etc*/
listMenu = document.querySelectorAll('[attr="value"]');
/* Recorremos listado de elementos */
for (var i = 0; i < listMenu.length; i++) {
/* Prevenimos evento por defecto del elemento */
listMenu[i].addEventListener("click", function(event){
event.preventDefault()
});
@agrogeek
agrogeek / MS_SQL_Server_find_field_table.sql
Created February 18, 2020 11:50
Consulta SQL para encontrar la columna [field_name] en todas las tablas de una BD en MS SQL Server.
SELECT sysobjects.name AS table_name, syscolumns.name AS column_name,
systypes.name AS datatype, syscolumns.LENGTH AS LENGTH
FROM sysobjects INNER JOIN
syscolumns ON sysobjects.id = syscolumns.id INNER JOIN
systypes ON syscolumns.xtype = systypes.xtype
WHERE (sysobjects.xtype = 'U')
and (UPPER(syscolumns.name) like upper('%field_name%'))
ORDER BY sysobjects.name, syscolumns.colid
@agrogeek
agrogeek / wp_write_log.php
Created February 24, 2020 15:47
Para escribir log en wp-content/debug.log. Valen string y objects
error_log( print_r( $log, true ) );