Skip to content

Instantly share code, notes, and snippets.

View nash-ye's full-sized avatar
🎯
Focusing

Nashwan Doaqan nash-ye

🎯
Focusing
View GitHub Profile
<?php
/**
* Priority Array
*
* @since 1.3
*/
class PriorityArray implements \IteratorAggregate, \ArrayAccess, \Serializable, \Countable {
/*** Properties ***********************************************************/
<?php
/**
* Event manager
*
* @since 1.3
*/
class EventManager {
/*** Properties ***********************************************************/
@nash-ye
nash-ye / functions.php
Last active August 29, 2015 14:05
A simple example to show the preferred way to change Momtaz current layout.
<?php
add_action( 'after_setup_theme', 'sample_after_setup_theme', 11 );
/**
* An action for 'after_setup_theme' hook.
*
* @return void
* @since 0.1
*/
@nash-ye
nash-ye / functions.php
Last active August 29, 2015 14:05
A simple example to show the preferred way to load a Momtaz module.
<?php
add_action( 'after_momtaz_setup', 'sample_after_momtaz_setup', 11 );
/**
* Load all the necessary code after Momtaz setup.
*
* @return void
* @since 0.1
*/
@nash-ye
nash-ye / functions.php
Last active August 29, 2015 14:06
Revert Back the Arabic "Widgets" Translation.
<?php
add_filter( 'gettext', 'change_widget_translation', 10, 3 );
/*
* Change the Arabic "Widgets" translation.
*
* @return string
*/
function change_widget_translation( $translations, $text, $domain ) {
@nash-ye
nash-ye / functions.php
Last active August 29, 2015 14:06
Retrieves post data given a post name, type and parent ID.
<?php
/**
* Retrieves post data given a post name, type and parent ID.
*
* @return WP_Post|NULL
*/
function get_post_by_name( array $args ) {
global $wpdb;
@nash-ye
nash-ye / hacks.php
Last active June 25, 2020 13:58
bbPress (Topics and Repiles) Numeric Permalinks
<?php
if ( ! did_action( 'bbp_after_setup_actions' ) ) {
add_action( 'bbp_after_setup_actions', 'n5n_after_bbPress_setup' );
} else {
n5n_after_bbPress_setup();
}
/**
* After bbPress Setup.
<?php
$hosts = [];
$doc = new DOMDocument();
$doc->loadHTMLFile("report-2015.html");
$historyTable = $doc->getElementById('history');
$historyTableRows = $historyTable->getElementsByTagName('tr');
@nash-ye
nash-ye / criteria-to-query-builder.php
Created May 24, 2016 01:59 — forked from jgornick/criteria-to-query-builder.php
Doctrine: Criteria Array to Doctrine QueryBuilder
<?php
/**
* Recursively takes the specified criteria and adds too the expression.
*
* The criteria is defined in an array notation where each item in the list
* represents a comparison <fieldName, operator, value>. The operator maps to
* comparison methods located in ExpressionBuilder. The key in the array can
* be used to identify grouping of comparisons.
*
(function($) {
'use strict';
$(function() {
$(document.body).one('click.add-media-button', '.insert-media', function(event) {
var orginalInsertCallback = wp.media.editor.insert;
wp.media.editor.insert = function(html) {
var image = $('img', $("<div>" + html + "</div>"));
if (! image.attr('alt')) {
var confirmed = confirm("An image without alternative text had been inserted!");
if (confirmed) {