Outils pour utilisateurs

Outils du site


informatique:wordpress

Wordpress

Documentation

Frameworks

http://wordpress.org/extend/plugins/options-framework/ - The Options Framework Plugin makes it easy to include an options panel in any WordPress theme. It was built so developers can concentrate on making the actual theme rather than spending time creating an options panel from scratch.

Pods Framework - Pods is a framework for WordPress that allows you to create, extend, manage, and deploy customized content types and fields.

NHP-Theme-Options-Framework - Simple, easy to use, very extendable Options framework for WP themes.

Redux-Framework a fork of NHP-Theme-Options-Framework.

Bedrock WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure. Gestion complète avec git & composer, arborescence fichiers différente de la native WP.

De bons développeurs de plugins et thèmes pour inspiration:

RGPD / GDPR

Remplace les fonts google de DIVI par une version copiée en local. Utilise le principe de wp_enqueue_script() et wp_enqueue_style()

Quelques plugins:

Sécuriser Wordpress

Sucuri, StackPath, SiteLock, Jetpack Security, Wordfence Security, BulletProof Security, iThemes Security, All In One WP Security & Firewall (AIOS), Shield Security

// Disallow file edit
define( 'DISALLOW_FILE_EDIT', true );

Monitoring & Observability

Wordfence

Pare-feu d'applications Web (WAF)

Wordfence

All-In-One Security (AIOS)

All-In-One Security (AIOS) – Security and Firewall (WAF)

https://wordpress.org/plugins/all-in-one-wp-security-and-firewall/

Two-factor (2FA)

Single Sign On (SSO)

Stream

Pour conserver les traces (QQQ) de toutes les actions dans Wordpress.

https://wordpress.org/plugins/stream/

PasswordLess

Admin Url

Changer l'url pour se connecter et de l'admin

    • a light plugin that lets you easily and safely change wp-login.php. It doesn’t literally rename or change files in core, nor does it add rewrite rules. It simply intercepts page requests and works on any WordPress website. The wp-admin directory and wp-login.php page become inaccessible, so you should bookmark or remember the url. Deactivating this plugin brings your site back exactly to the state it was before.
    • URL d’inscription et de mot de passe oublié: Il vous faut donner l’url. exemple : /login?action=register ou /login?action=lostpassword. Mais il n’y pas de redirection via le plugin, de l’url par défaut de WordPress (/wp-login.php?action=register ou /wp-login.php?action=lostpassword) sinon tout le monde pourrait connaître l’url d’administration de votre site.

Login with OAuth2

Le plugin de MiniOrange

Le plugin de Dash10 Digital

Celui de steve06

Le protocole OAuth fonctionne, mais que pour l'autorisation. Le problème est la récupération des infos du remote user pour mapper avec les wordpress users, il faut utiliser une API qui est propre à chaque service.

Ces plugins n'implémentent pas l'API de Nextcloud (OCS) donc pas compatible.

Le plugin wp_oauth2_client fonctionne avec Nextcloud

Tricks & Tips

"Une autre mise à jour est actuellement en cours"

  • Supprimer le fichier .maintenance à la racine du site ;
  • Supprimer les dossiers contenus dans le répertoire wp-content/upgrade ;
  • Supprimer la ligne wp_options.option_name = core_upgrader.lock.

Il se peut qu'il n'y ai aucun fichier mais seulement le ligne dan la BdD.

Modifier préfixe base de données WordPress

WP-Cli

Backup / Sauvegarde

Maintenance

Ce bout de code dans le functions.php du thème affiche un message aux visiteurs et permets toujours de se connecter via /wp-admin.

//
// Maintenance mode ===
//
function wp_maintenance_mode() {
 if (!current_user_can('edit_themes') || !is_user_logged_in()) {
  wp_die('<h1>Site de développement</h1><br/>Visitez le site <a href="https://site.prod">site.prod</a>');
 }
}
add_action('get_header', 'wp_maintenance_mode');

WP Query

Categories et tags

Dans une catégorie et dans d'autres:

$q = new \WP_Query([
  'cat'=> $cat->term_id,
  'category__in'=> $another_categories_term_id,
  ...

Customize Admin

WP-Cron

# Use system crontab
# */5 * * * * /usr/bin/wget -q -O - --delete-after https://xxxx.xx/wp-cron.php?doing_wp_cron
define('DISABLE_WP_CRON', true);

Flash message & co

Côté back

Côté front

Emoji

Si on ne veut pas des émojis il faut supprimer les actions wordpress associés :

// Stop Loading wp-emoji-release.min.js and CSS file
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );

Q & A

Nginx configuration

Cache

Wordpress gère nativement un cache (WordPress object cache) pour toutes ses données (transients, options, meta, posts, users …)

Avec APCu

  • Ne pas oublier de définir une clé unique pour le site quand mutualisation de php avec define('WP_APCU_KEY_SALT','<unique key>');
  • Un outil de visualisation de l'état d'APCu est fourni dans sa distribution, que l'on peut retrouver ici krakjoe/apcu ; prendre le fichier apc.php dans la release correspondante à celle installée

Avec Memcached

  • WordPress + Memcached One of the most bizarre critiques of WordPress that I often hear is “it doesn’t come with caching” – which makes no sense because Cache is one of the best features of WordPress out of the box

Autre trucs:

W3 Total Cache API

flush_pgcache()  //page cache
flush_dbcache()  // database cache
flush_minify()  // minify cache
flush_all() //all caches
 
// Clear all W3 Total Cache
if( class_exists('W3_Plugin_TotalCacheAdmin') )
{
    $plugin_totalcacheadmin = & w3_instance('W3_Plugin_TotalCacheAdmin');
 
    $plugin_totalcacheadmin->flush_all();
 
    echo __('<div class="updated"><p>All <strong>W3 Total Cache</strong> caches successfully emptied.</p></div>');
}

Varnish

WordPress with Varnish

Update files without FTP

In wp-config.php :

define('FS_METHOD','direct');

Load WordPress Posts With AJAX

Maintenir un plugin sur Github ou GitLab

Bug avec MySql et Inner Join

get post custom orderby

On ne peut pas mettre ce qu'on veut en $args['orderby'] de WP_Query … WP filtre avec WP_Query::parse_orderby().

Comment faire si j'ai besoin de ORDER BY min(wp_postmeta.meta_value) ASC ?

On peut utiliser un filter temporaire comme :

add_filter('posts_orderby', 'edit_posts_orderby');
function edit_posts_orderby($orderby_statement) {
    $orderby_statement = " term_taxonomy_id ASC ";
    return $orderby_statement;
}
query_posts($args);
remove_filter('posts_orderby', 'edit_posts_orderby');

Si c'est dans une recherche $q['s'] il y a le filtre posts_search_orderby appelé depuis WP_Query::get_posts().

Il y a aussi apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) ); qui est dans WP_Query::get_posts().

    public function dmach_archive_post_args_posts_orderby( $orderby )
    {
        $orderby = 'min(meta_value)' ; 
        remove_filter('posts_orderby', [$this,'dmach_archive_post_args_posts_orderby']);
        return $orderby ;
    }
 
    public function dmach_archive_post_args( $args )
    {
        Queries::fillWpQueryArgs( $args );
        add_filter('posts_orderby', [$this,'dmach_archive_post_args_posts_orderby']);
        return $args ;
    }

Background & Async

Job, Runner …

Youtube

Récupérer les videos d'une chaine (Channel) Youtube.

Une clé Google API est-elle nécessaire ?

Qlqs plugins

WP App Studio's plugins (free & not free).

Qlqs thèmes

Divi

Migrer un site:

Zerif-lite

oembed

WordPress oEmbed reconnait les URLs de quelques services et formate automatiquement le contenu à partir de l'URL (version >= 2.9).

WP filters:

    • Filters the cached oEmbed HTML
    • apply_filters( 'embed_oembed_html', string|false $cache, string $url, array $attr, int $post_ID )
    • Filters the returned oEmbed HTML
    • apply_filters( 'oembed_dataparse', string $return, object $data, string $url )

WP functions:

informatique/wordpress.txt · Dernière modification : 23/04/2024 18:11 de cyrille

Sauf mention contraire, le contenu de ce wiki est placé sous les termes de la licence suivante : CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki