Skip to content

Instantly share code, notes, and snippets.

View dongilbert's full-sized avatar
😍
Mautic WOOOO

Don Gilbert dongilbert

😍
Mautic WOOOO
View GitHub Profile
@dongilbert
dongilbert / sidebar_embed.php
Created June 4, 2012 17:37
Embed Sidebars In Content - WordPress
<?php
/**
* This code will allow you to embed a sidebar
* into a post or page or anywhere that shortcodes
* are parsed in your WordPress theme / site.
* It pairs well with Sidebar Generator
* http://wordpress.org/extend/plugins/sidebar-generator/
* Otherwise, be sure to register_sidebar('name')
*
@dongilbert
dongilbert / option_tree_shortcode.php
Created June 4, 2012 18:53
Shortcode for WP Option Tree
<?php
/**
* Shortcode to go along with my Option Tree
* helper functions. See those here:
* https://gist.github.com/2627998
*
* <samp>[theme_option name="home_text"]</samp>
*
* @param array Array of attributes passed from the shortcode.
* @return string|null
@dongilbert
dongilbert / config.php
Created August 2, 2012 14:18
Override Core Joomla! Classes
<?php
/**
* @package Joomla.Plugin
* @subpackage System.Overrides
*
* @copyright Copyright (C) 2012 Don Gilbert. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
define('OVERRIDES', dirname(__FILE__).'/overrides');
@dongilbert
dongilbert / sqlnono.php
Created September 5, 2012 21:18
How NOT to use SQL
<?php
$sql = sprintf( "SELECT `Password`, `DealerID`
FROM `DLMAST`
WHERE `DealerID` = %d
AND LOWER(`Password`) = '%s'",
mysql_real_escape_string( $_POST['Username'] ),
mysql_real_escape_string( strtolower( $_POST['Password'] ) ) );
$db->Execute( $sql, 'user_pass' );
@dongilbert
dongilbert / fixed.php
Created September 5, 2012 21:20
Not Enough Defines
<?php
$uri = parse_url($_SERVER['REQUEST_URI']);
$path = explode('/', $uri['path']);
define('IS_HOME', (empty($path[1])));
define('IS_ADMIN', ($path[1] === 'admin'));
define('IS_NEWS', ($path[1] === 'news'));
define('IS_CONTACT', ($path[1] === 'contact'));
@dongilbert
dongilbert / index.php
Created November 28, 2012 16:38
Joomla Namespace Example
<?php // File: index.php
const JPATH_BASE = __DIR__;
require_once JPATH_BASE . '/libraries/joomla/loader.php';
Joomla\Loader::registerNamespace('Joomla', JPATH_BASE . '/libraries/joomla');
Joomla\Application\Web::getInstance('\\Joomla\\Application\\Web')->execute();
@dongilbert
dongilbert / namespace.php
Last active May 12, 2019 11:25
Joomla Namespace Compatibility Layer
<?php
return array(
'JAccess' => 'Joomla\\Access\\Access',
'JAccessRule' => 'Joomla\\Access\\Rule',
'JAccessRules' => 'Joomla\\Access\\Rules',
'JApplicationBase' => 'Joomla\\Application\\Base',
'JApplicationCli' => 'Joomla\\Application\\Cli',
'JApplicationDaemon' => 'Joomla\\Application\\Daemon',
'JRoute' => 'Joomla\\Application\\Route',
@dongilbert
dongilbert / composer.json
Created November 29, 2012 01:03
Joomla Composer
{
"require": {
"joomla/platform": ">=13.2"
},
"minimum-stability": "dev",
"require-dev": {
"phpunit/phpunit": "3.7.*"
},
"config": {
"bin-dir": "bin",
@dongilbert
dongilbert / lead_controller.php
Created December 3, 2012 15:00
Joomla Export to CSV
<?php
/**
* @version 1.0.0
* @package com_stats
* @copyright Copyright (C) 2012. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access.
defined('_JEXEC') or die;
@dongilbert
dongilbert / example.md
Last active October 13, 2015 13:57
JHtml::asset()

Joomla Asset Management with JHtml

// To load a css file for a component, from within the component
EEHtml::asset('style.css');

// To load a js file for a module
EEHtml::asset('slide.js', 'mod_menu');

// To load an image for a module
echo EEHtml::asset('search.png', 'mod_product_search');