Skip to content

Instantly share code, notes, and snippets.

View sabrysuleiman's full-sized avatar

Sabry Suleiman sabrysuleiman

View GitHub Profile
@sabrysuleiman
sabrysuleiman / wp-navbar-schema-function.php
Last active May 28, 2019 09:10
function to add Site Navigation schema to wordpress site footer. >> https://schema.org/SiteNavigationElement
<?php
###########################################################
# Sabry Navbar Schema function
###########################################################
if (!function_exists('sabryschemanav')) {
function sabryschemanav(){
$menuLocations = get_nav_menu_locations();
$menuID = $menuLocations['header-menu'];
$primaryNav = wp_get_nav_menu_items($menuID);
@sabrysuleiman
sabrysuleiman / wp-contact-form-function.php
Last active May 28, 2019 09:08
Wordpress Contact Form Function
<?php
##################################################
## Wordpress Contact Form Function
##################################################
function html_form_code() {
echo '<form action="' . esc_url( $_SERVER['REQUEST_URI'] ) . '" method="post">';
echo '<p class="form-group">';
echo '<input required aria-label="Your Name (required)" placeholder="Your Name (required)" type="text" name="cf-name" pattern="[a-zA-Z0-9 ]+" value="' . ( isset( $_POST["cf-name"] ) ? esc_attr( $_POST["cf-name"] ) : '' ) . '" size="40" />';
@sabrysuleiman
sabrysuleiman / minify.php
Created August 26, 2019 09:01
A small PHP-Script for minifying CSS
<?php
// specify your css-files and their order here
$cssFiles = array(
'normalize.css', 'style.css', 'print.css', 'colorbox.css'
);
// the file to write the compressed css to
$minFileName = 'minified.css';
// thats all, just call this file in your browser and it will
// build you a minimized css-file. then just link to this single
@sabrysuleiman
sabrysuleiman / php-html-css-js-minifier.php
Created August 26, 2019 09:20 — forked from Rodrigo54/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
/**
* -----------------------------------------------------------------------------------------
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/system/kernel/converter.php`
* -----------------------------------------------------------------------------------------
*/
// HTML Minifier
function minify_html($input) {
@sabrysuleiman
sabrysuleiman / wp-image-upload-category.php
Created September 7, 2019 15:04
Wordpress image upload field category
if ( ! class_exists( 'CT_TAX_META' ) ) {
class CT_TAX_META {
public function __construct() {
//
}
/*
* Initialize the class and start calling our hooks and filters
@sabrysuleiman
sabrysuleiman / wp-image-upload-taxonomy.php
Created September 7, 2019 15:07
Wordpress Add Image Field To Taxonomy
if( ! class_exists( 'Showcase_Taxonomy_Images' ) ) {
class Showcase_Taxonomy_Images {
public function __construct() {
//
}
/**
* Initialize the class and start calling our hooks and filters
*/
<?php
$scripts = wp_scripts();
echo '<pre>';
print_r( $scripts );
echo '</pre><hr>';
$styles = wp_styles();
echo '<pre>';
print_r( $styles );
/**
* Unhook all action with some exception on wp_head and wp_footer
*/
function fr_unhook_wp_head_footer(){
global $wp_filter; // Where all the hooks and their actions are stored
// Actions that should not be removed from the wp_head hook
$wp_head_whitelist = array( 'wp_enqueue_scripts', 'wp_print_styles', 'wp_print_head_scripts' );
// Unhook actions from wp_head
@sabrysuleiman
sabrysuleiman / Simple Ajax Login Form.php
Created September 26, 2019 14:54 — forked from cristianstan/Simple Ajax Login Form.php
Wordpress: Simple Ajax Login Form
<?php
//Simple Ajax Login Form
//Source: http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/
//html
<form id="login" action="login" method="post">
<h1>Site Login</h1>
<p class="status"></p>
<label for="username">Username</label>
<input id="username" type="text" name="username">
@sabrysuleiman
sabrysuleiman / functions.php
Created September 26, 2019 14:54 — forked from vishalbasnet23/functions.php
User Registration Front End WordPress with Ajax
<?php
add_action('wp_ajax_register_user_front_end', 'register_user_front_end', 0);
add_action('wp_ajax_nopriv_register_user_front_end', 'register_user_front_end');
function register_user_front_end() {
$new_user_name = stripcslashes($_POST['new_user_name']);
$new_user_email = stripcslashes($_POST['new_user_email']);
$new_user_password = $_POST['new_user_password'];
$user_nice_name = strtolower($_POST['new_user_email']);
$user_data = array(
'user_login' => $new_user_name,