Skip to content

Instantly share code, notes, and snippets.

@em-piguet
em-piguet / changeValue.php
Last active August 29, 2015 14:13
Batch resources value in MODX
/*
[[changeValue? &parent=`` &field=`` &value=`` ]]
*/
foreach ($modx->getIterator('modResource', array('parent' =>$parent)) as $res) {
$res->set($field,$value);
$res->save();
echo ($action.'=>'.$value.'! <br/>');
@em-piguet
em-piguet / findReplaceTV.php
Last active August 29, 2015 14:13
Batch Find and Replace a value in a MODX TV
<?php
/*
Name:
findReplaceTV
Description :
This snippet is useful if you want to batch replace a string in multiple resources at once.
@em-piguet
em-piguet / wp_changeLoginUrl.php
Last active August 11, 2025 13:45 — forked from tazeverywhere/wp_changeLoginUrl.php
WP - change login/admin URL
<?php
//////////////////////
// SECURE WP_ADMIN //
//////////////////////
// ---- 1. edit wp-config.php
/* tells wordpress what the new directory is, and updates the cookie path.
define( 'WP_ADMIN_DIR', 'manager' );
define( 'ADMIN_COOKIE_PATH', '/' );
*/
@em-piguet
em-piguet / site.conf
Last active September 14, 2015 14:04 — forked from markwillis82/site.conf
nginx config setup for modx + statcache
server {
root /path/to/site;
index index.php;
server_name somedomain.co.uk www.somedomain.co.uk;
set $cache_uri $request_uri;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $cache_uri 'null cache';
@em-piguet
em-piguet / article2collections.sql
Created March 30, 2016 09:59
How to convert an MODX articles container to a MODX collections container...
# switch ArticlesContainer -> CollectionContainer
# the res. ID I want to migrate is 11
UPDATE `modx_site_content` SET `class_key` = replace(class_key, 'ArticlesContainer', 'CollectionContainer') WHERE id=11;
# switch class_key to go back to default document view for children
UPDATE `modx_site_content` SET `class_key` = replace(class_key, 'Article', 'modDocument') WHERE parent=11;
# Change template 49 -> 57
@em-piguet
em-piguet / show_current_template.php
Last active February 8, 2017 17:39
Helper for dev in wordpress
<?php
function show_current_template($wp_admin_bar)
{
global $template;
$args = array(
'id' => 'current_template',
'title' => basename($template),
'meta' => array('title' => $template),
);
$wp_admin_bar->add_node($args);
@em-piguet
em-piguet / isdev.php
Last active February 8, 2017 17:38
Helper for dev in Wp
<?php
/*
* Returns true if we are working on a development server, determined by server's
* hostname. Will generate an error if run on an unknown host.
*/
function isdev()
{
$isdev = null;
// don't run function body more than once
@em-piguet
em-piguet / add_tab_myaccount.php
Last active December 16, 2024 16:25
WOOCOMMERCE add page in my account
<?php
/**
* Ajoute un tab/endpoints dans la partie mon compte
* https://nicola.blog/2017/08/01/add-enquiry-form-my-account-woocommerce-contact-form-7/
*
*/
class WC_Custom_My_Account_Tabs extends WC_Query {
/**
* Adds main filters and actions and inits the endpoints.
@em-piguet
em-piguet / woocommerce_script_cleaner.php
Last active October 28, 2019 18:07
Manage WooCommerce styles and scripts
<?php
////////////////////////////////////////////
// Manage WooCommerce styles and scripts. //
////////////////////////////////////////////
function woocommerce_script_cleaner() {
// Remove the generator tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
// remove definitly, no need of this one
///////////////////////////////////////////////////
<?php
/**
* This is a muplugin
*
* Indexation des champs ACF "Auteurs" (relationnel) et "Année" (post_date) dans Elasticsearch index
* pour WPSOLR
*/
use wpsolr\core\classes\WPSOLR_Events;