IndexNow Plugin

Descripció
El connector IndexNow per a WordPress permet l’enviament automàtic d’URL dels llocs de WordPress als diversos motors de cerca sense necessitat de registrar-se i verificar el vostre lloc amb ells. Un cop instal·lat, el connector generarà i allotjarà automàticament la clau API al vostre lloc. Detecta la creació/actualització/supressió de pàgines a WordPress i envia automàticament els URL en segon pla. Això garanteix que els motors de cerca sempre tindran les últimes actualitzacions sobre el vostre lloc. Aquest connector envia URL a un punt final genèric “https://api.indexnow.org/indexnow” i aquests URL es comparteixen amb tots els motors de cerca participants.

Enlaç: https://wordpress.org/plugins/indexnow/

No provat encara…

Extendify — Gutenberg Patterns and Templates

Descripció:
Extendify és la plataforma d’eines de disseny i creació de llocs per a persones que volen crear un bell lloc web de WordPress amb una biblioteca de patrons i dissenys de pàgina completa per a l’editor de blocs Gutenberg.

Feu que un bell lloc web de WordPress sigui més fàcil i ràpid que mai amb la biblioteca d’Extendify de patrons de blocs, plantilles i dissenys de pàgina per a Gutenberg.

Enllaç: https://wordpress.org/plugins/extendify/

Per provar encara…

Afegim a la url del CTP la taxonomia

Codi per afegir a la url d’un Cutsom Post Type, una taxonomia.

Ex:
Passem de: Domini/directorio/slug-post/
A: Domini/directorio/Taxonomia/slug-post/

A tindre en compte: quan declarem el CTP, l’opció de slug ha de tindre un, en el cas de l’exemple una forma com: directorio/%tax%

El codi el que fa és substituir el %tax% per la categoria i després fem la configuració del rewrite perquè aquests enllaços no siguin 404.

/**
 * 	Afegim a la url de wordpress la taxonomia
 * 	Fem servir el "post_type_link" per trucar el link
 * 	Fem servir el "generate_rewrite_rules" perque no surti 404 al visitar el link trucat.
 * 	Hem de referscar els enllaços permanets
 * 
 * 
 */
add_filter('post_type_link', 'my_custom_permalink', 10, 3);
function my_custom_permalink($permalink, $post_id, $leavename)
{
	if ((strpos($permalink, '%tax%') === FALSE)) // %tax% -> string que posem al slug del CTP. Ex: directorio/%tax%
		return $permalink;
	$post = get_post($post_id);
	if (!$post) return $permalink;
	$y_terms = wp_get_object_terms($post->ID, 'categorias_directorio'); // canviar per el nom de la categoria
	if (!is_wp_error($y_terms) && !empty($y_terms) && is_object($y_terms[0])) $y_taxonomy_slug = $y_terms[0]->slug;
	return str_replace('%tax%', $y_taxonomy_slug, $permalink); // %tax%
}
function directorio_cpt_generating_rule($wp_rewrite)
{
	$rules = array();
	$terms = get_terms(array(
		'taxonomy' => 'categorias_directorio', // canviar per el nom de la categoria
		'hide_empty' => false,
	));
	$post_type = 'directorio'; // canviar per el nom del CTP
	foreach ($terms as $term) {
		// canviar per el slug del CTP. Primera part nom normal. Taxonomia. Nom del CTP.
		$rules['directorio/' . $term->slug . '/([^/]*)$'] = 'index.php?post_type=' . $post_type . '&directorio=$matches[1]&name=$matches[1]';
	}
	// merge with global rules
	$wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
add_filter('generate_rewrite_rules', 'directorio_cpt_generating_rule');

Crear usuari admin amb PHP

<?php
function wpb_admin_account()
{
    $user = 'Username';
    $pass = 'Password';
    $email = 'email@domain.com';
    if (!username_exists($user)  && !email_exists($email)) {
        $user_id = wp_create_user($user, $pass, $email);
        $user = new WP_User($user_id);
        $user->set_role('administrator');
    }
}
add_action('init', 'wpb_admin_account');
 ?>

Llista de Hooks per la bloc de ‘Post Grid’ de Kadence Theme Pro

add_action( 'kadence_blocks_post_no_posts', array( $this, 'get_no_posts' ), 15 );
add_action( 'kadence_blocks_post_loop_header', array( $this, 'get_above_categories' ), 10 );
add_action( 'kadence_blocks_post_loop_start', array( $this, 'get_post_image' ), 20 );
add_action( 'kadence_blocks_post_loop_header', array( $this, 'get_post_title' ), 20 );
add_action( 'kadence_blocks_post_loop_header', array( $this, 'get_meta_area' ), 30 );
add_action( 'kadence_blocks_post_loop_header_meta', array( $this, 'get_meta_date' ), 10 );
add_action( 'kadence_blocks_post_loop_header_meta', array( $this, 'get_meta_modified_date' ), 12 );
add_action( 'kadence_blocks_post_loop_header_meta', array( $this, 'get_meta_author' ), 15 );
add_action( 'kadence_blocks_post_loop_header_meta', array( $this, 'get_meta_category' ), 20 );
add_action( 'kadence_blocks_post_loop_header_meta', array( $this, 'get_meta_comment' ), 25 );
add_action( 'kadence_blocks_post_loop_content', array( $this, 'get_post_excerpt' ), 20 );
add_action( 'kadence_blocks_post_loop_content', array( $this, 'get_post_read_more' ), 30 );
add_action( 'kadence_blocks_post_loop_footer_start', array( $this, 'get_post_footer_date' ), 10 );
add_action( 'kadence_blocks_post_loop_footer_start', array( $this, 'get_post_footer_categories' ), 15 );
add_action( 'kadence_blocks_post_loop_footer_start', array( $this, 'get_post_footer_tags' ), 20 );
add_action( 'kadence_blocks_post_loop_footer_end', array( $this, 'get_post_footer_author' ), 10 );
add_action( 'kadence_blocks_post_loop_footer_end', array( $this, 'get_post_footer_comments' ), 15 );

Ruta: /wp-content/plugins/kadence-blocks-pro/dist/dynamicblocks/class-kadence-blocks-pro-post-grid.php

Ex:

// add content on post grid block
add_action('kadence_blocks_post_loop_header', 'add_maquinaria_meta', 30);
function add_maquinaria_meta()
{
	// si es CPT maquinaria
	if (get_post_type( ) === 'maquina') {
		$capacidad_de_carga = get_field('capacidad_de_carga');
		if ($capacidad_de_carga) {
			echo '<div class="capacidad-de-carga">' . $capacidad_de_carga . '</div>';
		}
	}
}

Afegim accions dins de les llistes de post a l’admin

/**
 * Afegim accions dins de les llistes de media l'admin
 */
function modify_list_row_actions($actions, $post) {
    // Build your links URL.
    $url = wp_get_attachment_image_url($post->ID);
    $actions['see'] = sprintf(
            '<a href="%1$s" targte="blank">%2$s</a>',
            esc_url($url),
            esc_html(__('Ver Media', 'infinite'))
    );
    return $actions;
}
add_filter('media_row_actions', 'modify_list_row_actions', 10, 2);

Si volem fer el mateix a posts, hem de canviar el filtre i podem afegir un of per filtrar per custo post type. Exemple:

add_filter('post_row_actions', 'modify_list_row_actions', 10, 2);
function modify_list_row_actions($actions, $post)
{
    // Check for your post type.
    if ($post->post_type == "attachment") {
        // Build your links URL.
        $url = wp_get_attachment_image_url($post->ID);
        // Maybe put in some extra arguments based on the post status.
        $edit_link = add_query_arg(array('action' => 'view'), $url);
        // The default $actions passed has the Edit, Quick-edit and Trash links.
        $trash = $actions['trash'];
        /*
		 * You can reset the default $actions with your own array, or simply merge them
		 * here I want to rewrite my Edit link, remove the Quick-link, and introduce a
		 * new link 'Copy'
		 */
        $actions = array(
            'view' => sprintf(
                '<a href="%1$s">%2$s</a>',
                esc_url($edit_link),
                esc_html(__('View', 'infinite'))
            )
        );
    }
    return $actions;
}
add_filter('post_row_actions', 'modify_list_row_actions', 10, 2);

Afegim un shortcode per les plantilles de Elementor


/**
 *  Enable the use of short codes in text widgets.
 */
add_filter('widget_text', 'do_shortcode');
add_filter('manage_elementor_library_posts_columns', 'prefix_edit_elementor_library_posts_columns');
function prefix_edit_elementor_library_posts_columns($columns)
{
	$columns['prefix_shortcode_column'] = esc_html__('Shortcode', 'text_domain');
	return $columns;
}
add_action('manage_elementor_library_posts_custom_column', 'prefix_add_elementor_library_columns', 10, 2);
function prefix_add_elementor_library_columns($column, $post_id)
{
	switch ($column) {
		case 'prefix_shortcode_column':
			echo '<input type="text" class="widefat" value=\'[elementor-template id="' . $post_id . '"]\' readonly>';
			break;
	}
}
add_shortcode('elementor-template', 'prefix_add_elementor');
function prefix_add_elementor($atts)
{
	if (!class_exists('Elementor\Plugin')) {
		return false;
	}
	if (!isset($atts['id']) || empty($atts['id'])) {
		return false;
	}
	$post_id  = $atts['id'];
	$response = Elementor\Plugin::instance()->frontend->get_builder_content_for_display($post_id);
	return $response;
}