Skip to content

Instantly share code, notes, and snippets.

View mhmoudsami's full-sized avatar

Sami El mhmoudsami

  • germany
  • 13:48 (UTC -12:00)
View GitHub Profile
@mhmoudsami
mhmoudsami / vhosts.sh
Created July 25, 2016 14:47 — forked from aamnah/vhosts.sh
Bash script to create Virtual host files [source](http://ubuntuforums.org/showthread.php?t=2106950)
#!/bin/bash
# Source: http://ubuntuforums.org/showthread.php?t=2106950
#Check for root
true="true"true="true"
ROOT_UID=0
overwrite=""
if [ "$UID" -ne "$ROOT_UID" ]; then
echo "Must be run as root, use sudo."
exit 0
fi
@mhmoudsami
mhmoudsami / install-wp.sh
Created July 25, 2016 14:43 — forked from aamnah/install-wp.sh
Install WordPress via Shell
# Colors
Color_Off='\033[0m' # Color Reset
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Cyan='\033[0;36m' # Cyan
# Bold
BRed='\033[1;31m' # Red
BGreen='\033[1;32m' # Green
@mhmoudsami
mhmoudsami / vhost.sh
Created July 25, 2016 14:40 — forked from aamnah/vhost.sh
Bash script to create virtual host file
#!/bin/sh
############
# Author: Aamnah
# URL: http://aamnah.com
# Based on: https://www.linode.com/docs/websites/hosting-a-website
############
# Reset
Color_Off='\033[0m' # Text Reset
@mhmoudsami
mhmoudsami / wp_pagination
Last active July 24, 2016 15:47
wordpress paginate_link that supports custom wp_query
if (! function_exists('prefix_Pagination')) :
/**
* Pagination.
*
* @link https://codex.wordpress.org/Function_Reference/paginate_links
* @param array $options paginate_links options
* @param wp_query $query wp_query
* @return mixed false if no paging or pagination html string
*/
function prefix_Pagination($options=[], $wp_query = null)
@mhmoudsami
mhmoudsami / wp_is_static
Created July 24, 2016 15:36
wordpress check if home page is static meaning if current page is home and front page displays custom template
if (! function_exists('prefix_is_static')) :
/**
* is static page
* check if current page is home and front page displays custom template
*
* @return boolean is static ?
*/
function prefix_is_static()
{
return (is_front_page() && 'posts' !== get_option( 'show_on_front' ));
@mhmoudsami
mhmoudsami / color_luminance.php
Created July 17, 2016 12:48 — forked from stephenharris/color_luminance.php
Lighten or darken a given colour
<?php
/**
* Lightens/darkens a given colour (hex format), returning the altered colour in hex format.7
* @param str $hex Colour as hexadecimal (with or without hash);
* @percent float $percent Decimal ( 0.2 = lighten by 20%(), -0.4 = darken by 40%() )
* @return str Lightened/Darkend colour as hexadecimal (with hash);
*/
function color_luminance( $hex, $percent ) {
// validate hex string
@mhmoudsami
mhmoudsami / post end point with custom template
Created July 15, 2016 15:44
wp custom post endpoint with custom template
if ( ! function_exists('Marvel_add_custom_endpoints') ):
/**
* Add Custom End points
*/
function Marvel_add_custom_endpoints()
{
// End Point For Single Event Subscribers
add_rewrite_endpoint( 'subscribers', EP_PERMALINK );
flush_rewrite_rules();
@mhmoudsami
mhmoudsami / admin nav menu metabox
Created July 15, 2016 15:42
custom admin nav menu predefined set of links
/**
* @link https://gist.github.com/certainlyakey/11441175
*/
function Marvel_add_admin_nav_menu_metabox()
{
add_meta_box('marvel-metabox-nav-menu-custom', 'Marvel Links', 'Marvel_admin_nav_menu_metabox_callback', 'nav-menus', 'side', 'default');
}
add_action('admin_head-nav-menus.php', 'Marvel_add_admin_nav_menu_metabox');
function Marvel_admin_nav_menu_metabox_callback()
@mhmoudsami
mhmoudsami / _wordpress_core.scss
Created June 28, 2016 14:54 — forked from lgladdy/_wordpress_core.scss
WordPress Core Styles in SASS
/* =WordPress Core - Sassified.
-------------------------------------------------------------- */
.alignnone {
margin: 5px 20px 20px 0;
}
.aligncenter, div.aligncenter {
display: block;
margin: 5px auto 5px auto;
}
@mhmoudsami
mhmoudsami / README.md
Created June 28, 2016 14:42 — forked from tomazzaman/README.md
Gulp workflow for WordPress theme development

Gulp workflow for WordPress theme development

Requirements

In order for Livereload to work, you need a Firefox or Chrome extension as Gulp doesn't inset it automatically. Alternatively, you can also manually put the livereload script in footer.php, just make sure to insert it only on development environment:

<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>