Skip to content

Instantly share code, notes, and snippets.

View luclemo's full-sized avatar

Lucas Lemonnier luclemo

  • Ste-Justine Hospital Research Center
  • Montreal, QC
View GitHub Profile
@luclemo
luclemo / customize-password-protected-text.php
Created March 21, 2019 18:37
Add text to your password form, modify the HTML form, change the default `Protected:` title prefix. #wordpress
<?php
/**
* If you want to add text to your password form
*
* @link https://developer.wordpress.org/reference/hooks/the_password_form/
*/
add_action( 'the_password_form', 'll_the_password_form' );
function ll_the_password_form( $output )
{
@luclemo
luclemo / password-protect-custom-fields.php
Created March 21, 2019 18:23
Protect custom fields if they are on a password protected page #wordpress
<?php
/**
* Add custom fields to password protected blocks
*
* @link https://wordpress.org/support/article/using-password-protection/#protect-custom-fields
*/
if ( ! post_password_required() ) {
// Your ACF code goes here.
<?php
/**
* Create global vaiable for accepted HTML tags in ACF fields.
*
* To be used with wp_kses. Example:
* wp_kses( get_field( 'field' ), ll_allowed_markup() );
*
* @link https://codex.wordpress.org/Function_Reference/wp_kses
*/
@luclemo
luclemo / emailbot_ssc.php
Last active October 22, 2018 19:13 — forked from norcross/emailbot_ssc.php
Obfuscate email shortcode #wordpress
/*
Usage (on the HTML tab, not the visual editor)
[email address="[email protected]"]
*/
function emailbot_ssc($attr) {
extract( shortcode_atts( array(
'address' => '',
), $attr ) );
@luclemo
luclemo / flex-field-by-page-id.php
Last active October 17, 2018 14:43
Get Sub Field From ACF’s Flexible Content Field #wordpress #ACF
<?php
/*
* Get a sub field from within a layout of a flexible content field on a specific page
* @param string $flexFieldName The flexible content field name
* @param string $flexFieldLayoutName The flexible content's layout name
* @param string $flexFieldLayoutField The FCs layout's sub field name
* @return string If exists, then returns the value of the layout's sub field. If not, then it returns a message.
*/
@luclemo
luclemo / disable-comments.php
Last active October 17, 2018 14:44 — forked from alexwoollam/function.php
Wordpress Disable Comments (add to function.php)
<?php
/**
* Disables comments, Add below to existing function.php file.
*/
/** Disable support for comments and trackbacks in post types. */
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ( $post_types as $post_type ) {
if ( post_type_supports( $post_type, 'comments' ) ) {
@luclemo
luclemo / language-checker.php
Last active August 5, 2018 19:45
Function for checking language #wordpress
<?php
// Language ckecker test
if (get_locale() == 'fr_FR') :
echo "bonjour la France";
elseif (get_locale() == 'fr_CA') :
echo "bonjour le Québec";
else : echo "hello";
endif;
@luclemo
luclemo / remove-menus.php
Last active June 20, 2018 20:11
Removes menu items from WordPress dashboard #wordpress
<?php
// Removes menu items from wordpress dashboard for all users
function remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'jetpack' ); //Jetpack*
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media

First add the svg sprite to the markup, just after the opening body tag or just before closing body tag:

/* Example sprite of 4 icons */

<svg class="icon-sprite" style="width: 0; height: 0;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <symbol id="icon-chat" viewBox="0 0 24 24">
      <title>chat</title>
      <path d="M20.029 15.99v-12.019h-16.058v14.038l2.019-2.019h14.038zM20.029 2c0.545 0 1.010 0.192 1.394 0.577s0.577 0.849 0.577 1.394v12.019c0 0.545-0.192 1.018-0.577 1.418s-0.849 0.601-1.394 0.601h-14.038l-3.99 3.99v-18.029c0-0.545 0.192-1.010 0.577-1.394s0.849-0.577 1.394-0.577h16.058z"></path>
@luclemo
luclemo / gravity-forms-date-timestamp.php
Last active February 25, 2017 19:24 — forked from spivurno/gist:5065194
Use Gravity Forms Conditional Logic with Dates #wordpress #gravityForms
<?php
/**
* Use Gravity Forms Conditional Logic with Dates
* http://gravitywiz.com/use-gravity-forms-conditional-logic-with-dates/
*/
add_filter("gform_field_value_timestamp", "gwiz_populate_timestamp");
function gwiz_populate_timestamp( $value ){
return time();
}