Skip to content

Instantly share code, notes, and snippets.

View gmaggio's full-sized avatar

Giraldi Maggio gmaggio

View GitHub Profile
@gmaggio
gmaggio / wp-menu-item-name.php
Created July 26, 2014 03:25
[Wordpress] Get the Menu Name of the current page
<?php
/**
* Get the Menu Name of the current page
*
* $loc is the location name of the nav menu
*
* Source:
* http://wordpress.stackexchange.com/a/155833/1044
*
*/
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'dart:math' as math;
class CustomLayout extends MultiChildRenderObjectWidget {
CustomLayout({
Key key,
List<Widget> children = const <Widget>[],
}) : super(key: key, children: children);
@gmaggio
gmaggio / wp-page-subpage-menu.php
Created July 25, 2014 01:58
[Wordpress] Display Child Pages on the Parent Page (including the Parent Page itself)
<?php
/**
* Display Child Pages on the Parent Page
* (including the Parent Page itself)
*
* Sources:
* - http://codex.wordpress.org/Function_Reference/wp_list_pages
* - http://www.wpbeginner.com/wp-tutorials/how-to-display-a-list-of-child-pages-for-a-parent-page-in-wordpress/
* - http://www.svennerberg.com/2009/02/creating-a-submenu-in-wordpress/
*/
@gmaggio
gmaggio / wp-admin-pages-orderby-menuorder.php
Created August 10, 2014 01:48
[Wordpress] Set the MENU ORDER as the default sorting order for PAGES in ADMIN. Source: http://wordpress.org/support/topic/sort-pages-by-date-in-admin-by-default?replies=4#post-5380257
<?php
/**
* Order Admin Pages by Menu Order by Default
*
* Source:
* http://wordpress.org/support/topic/sort-pages-by-date-in-admin-by-default?replies=4#post-5380257
*
*/
add_filter('pre_get_posts', 'my_set_post_order_in_admin' );
@gmaggio
gmaggio / wp-add-class-next_prev_post_links.php
Created July 20, 2014 17:11
[Worpress] Add class to next/previous post links (Add class to links generated by next_posts_link & previous_posts_link)
<?php
/**
* Add class to next/previous post links
*
* Add class to links generated by next_posts_link
* and previous_posts_link
*/
if ( ! function_exists( 'posts_link_attributes_prev' ) || ! function_exists( 'posts_link_attributes_next' ) ) {
function posts_link_attributes_prev() {
@gmaggio
gmaggio / yahoo-online-status-detection.php
Created July 8, 2014 11:42
[Yahoo] Yahoo Messenger Online/Offline Status Detection #soical-media
<?php
$yahooID = "YOUR_ID";
$status = file_get_contents("http://opi.yahoo.com/online?u=".$yahooID."&m=a&t=1");
if ($status === '00') {
echo "OFFLINE!";
} else if ($status === '01') {
echo "ONLINE!";
@gmaggio
gmaggio / table-date-range.php
Created March 16, 2016 10:51
Programmatically create table that contains rowspan to distinguish date range based on month.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Table with date range</title>
<script type="text/javascript">
</script>
# Note: Higher number equals higher priority
# to indicate greater relevancy
SELECT *,
(CASE WHEN attribute1_field = attribute1_value THEN 2 ELSE 0 END) +
(CASE WHEN attribute2_field = attribute2_value THEN 1 ELSE 0 END) +
(CASE WHEN attribute3_field = attribute3_value THEN 1 ELSE 0 END) AS priority
FROM table_post
WHERE (
attribute1_field = attribute1_value
@gmaggio
gmaggio / wp-admin-dashboard-items-remove.php
Created August 10, 2014 03:31
[Wordpress] Remove Unwanted Dashboard Items
<?php
/**
* Remove Unwanted Dashboard Items
*
* Source:
* Point #25 @ https://managewp.com/enhanced-performance-code-snippets
*
*/
add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');
function my_custom_dashboard_widgets() {
<?php
/**
* Automatically set Menu Order on create new page
*
* Source:
* http://wordpress.stackexchange.com/a/155979/1044
*
*/
add_action( 'admin_footer-post-new.php', 'my_admin_footer_post_new_php' );