Skip to content

Instantly share code, notes, and snippets.

View moabi's full-sized avatar
🎯
Focusing

David Fieffé moabi

🎯
Focusing
View GitHub Profile
@moabi
moabi / twitter wordpress widget.php
Last active October 15, 2015 12:05
twitter wordpress widget - name edition
<?php
class Last_Tweets extends WP_Widget {
/**
* Register widget with WordPress.
*/
function __construct() {
parent::__construct(
'Last-post', // Base ID
__('Lyra Network - Last Tweets', 'twentyfifteen'), // Name
@moabi
moabi / Wordpress menu widget
Created June 11, 2015 15:01
retrieve a menu and format it
/**
* MENU widget
*
*/
class menu_widget extends WP_Widget {
/**
* Register widget with WordPress.
*/
@moabi
moabi / gist:f207c7a0c5eb9310f07a
Created June 17, 2015 05:24
Redirect if only one post in category - wordpress
function stf_redirect_to_post(){
global $wp_query;
if( is_archive() && $wp_query->post_count == 1 ){
the_post();
$post_url = get_permalink();
// Redirect to post page
wp_redirect( $post_url );
}
}
add_action('template_redirect', 'stf_redirect_to_post');
@moabi
moabi / lockdown_WP.txt
Last active September 16, 2015 07:47
lockdown wordpress rights
<?php
/**
*
* Description : lockdown wordpress rights
* version 1.0
*
*/
$mode = '';
$path_rights = array(
array(
@moabi
moabi / class-backend-tables.php
Created December 10, 2015 19:59 — forked from wturnerharris/class-backend-tables.php
This is an example of extending the default class for tables in the admin section, WP_List_Table. It does take some setup arguments, but works and looks seamlessly within WordPress.
<?php
if(!class_exists('WP_List_Table')) require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
/**
* Extended class for displaying a list of items in an HTML table.
*
* @usage
* // be sure to modify the display_rows function to customize the output of the rows
* $args = array(
@moabi
moabi / README.md
Created January 21, 2016 10:52
Jekyll - list directories from a path

usage

{% directory_list directory:products/tea iterator:item sort:descending %}
  {{ item }}

{% enddirectory_list %}

@moabi
moabi / pure_walker_nav_menu.php
Last active April 20, 2017 03:35
Wordpress walker nav menu to pure.css dropdown menu
<?php
/**
* Will add classes to create a pure.css dropdown menu
* Usage
* wp_nav_menu(array(
* 'theme_location' => 'primary',
* 'menu_class' => 'pure-menu-list',
* 'container_class' => 'pure-menu pure-menu-horizontal',
* 'walker' => new pure_walker_nav_menu
* ));
@moabi
moabi / Form_to_sessionStorage.js
Created December 29, 2016 08:48
store inputs/selects to sessionsStorage, if page is reloaded, set form inputs values
/**
* 1/ onLoad, retrieve session storage data (ALL OF IT !!! - so carefull)
* 2/ the key === input/select ID
* 3/ set the value
*/
window.onload = function () {
if (sessionStorage) {
for (i = 0; i < sessionStorage.length; i++) {
var key = sessionStorage.key(i);
var value = sessionStorage[key];
@moabi
moabi / bulma_walker_nav_menu.php
Last active August 2, 2021 12:09
A wordpress walker for Bulma Nav component
<?php
/**
* Will add classes to create bulma menu in wordpress
* http://bulma.io/documentation/components/nav/
* Usage
* wp_nav_menu(array(
* 'theme_location' => 'primary',
* 'items_wrap' => '%3$s',
* 'container_class' => 'nav-right nav-menu',
* 'walker' => new bulma_walker_nav_menu
@moabi
moabi / widget-terms.php
Last active May 8, 2017 07:52
add a widget for terms listing from a custom taxonomy with child, description, count options
<?php
/**
* Created by PhpStorm.
* User: david1
* Date: 07/05/2017
* Time: 13:32
*/
/**
* Adds Foo_Widget widget.
*/