Skip to content

Instantly share code, notes, and snippets.

View N-Molham's full-sized avatar
🇦🇮

Nabeel Molham N-Molham

🇦🇮
View GitHub Profile
@N-Molham
N-Molham / plugin-master-file.php
Last active August 29, 2015 14:11
WordPress plugins master file template snippet
<?php
/*
Plugin Name: Dashboard User Password Generator
Plugin URI: http://nabeel.molham.me/blog/plugins/user-password-generator-demo
Description: Add a generator button next password field in the dashboard
Version: 1.0
Author: Nabeel Molham
Author URI: http://nabeel.molham.me/
Text Domain: user-password-generator-demo
Domain Path: /languages
@N-Molham
N-Molham / master.php
Last active August 29, 2015 14:12
Dashboard User Password Generator demo plugin main file
<?php
/*
Plugin Name: Dashboard User Password Generator
Plugin URI: http://nabeel.molham.me/blog/plugins/user-password-generator-demo
Description: Add a generator button next password field in the dashboard
Version: 1.0
Author: Nabeel Molham
Author URI: http://nabeel.molham.me/
Text Domain: user-password-generator-demo
Domain Path: /languages
@N-Molham
N-Molham / master.php
Last active August 29, 2015 14:12
Dashboard User Password Generator demo plugin main file header
/*
Plugin Name: Dashboard User Password Generator
Plugin URI: http://nabeel.molham.me/blog/plugins/user-password-generator-demo
Description: Add a generator button next password field in the dashboard
Version: 1.0
Author: Nabeel Molham
Author URI: http://nabeel.molham.me/
Text Domain: user-password-generator-demo
Domain Path: /languages
License: GNU General Public License, version 2, http://www.gnu.org/licenses/gpl-2.0.html
@N-Molham
N-Molham / master.php
Last active August 29, 2015 14:12
Dashboard User Password Generator demo plugin - generator UI hook
<?php
// in the User_Password_Generator_Demo class constructor
// password hint content filter
add_filter( 'password_hint', array( &$this, 'generator_ui' ) );
// add new methon to User_Password_Generator_Demo class
// which will be the callback
/**
* Password Generator UI
*
@N-Molham
N-Molham / master.php
Created December 24, 2014 16:58
Dashboard User Password Generator demo plugin - generator assets
<?php
// in the User_Password_Generator_Demo class constructor
// Dashboard hook for add js and css files
add_action( 'admin_enqueue_scripts', array( &$this, 'enqueues' ) );
// add new methon to User_Password_Generator_Demo class
/**
* Assets Enqueues
*
* @since 1.0
@N-Molham
N-Molham / generator.css
Created December 24, 2014 17:03
Dashboard User Password Generator demo plugin - generator styling
@CHARSET "UTF-8";
/* fix checkbox width */
/* تظبيط عرض */
#createuser .form-field input[type=checkbox] {
width: auto;
}
/* set the width of password character length field */
/* بجبر العرض حسب ما بحتاح */
@N-Molham
N-Molham / generator.js
Created December 24, 2014 17:10
Dashboard User Password Generator demo plugin - generator Javascript
/**
* Password Generator
*/
( function( w ) {
jQuery( function( $ ) {
// reference inputs for later use
var $user_special = $( '#generator-use-special' ),
$use_extra_special = $( '#generator-use-extra' ),
$password_length = $( '#generator-length' ),
$password_result = $( '#generator-result' ),
@N-Molham
N-Molham / example.php
Created February 9, 2015 17:22
Handling inputs' errors - that is one way to go
<?php
$con = mysqli_connect( 'localhost' , 'root' , '' , 'market' );
// Inputs from post
$inputs = filter_input_array( INPUT_POST, $_POST, [
'kind' => FILTER_SANITIZE_STRING,
'salary' => FILTER_SANITIZE_NUMBER_FLOAT,
'advantage' => FILTER_SANITIZE_STRING,
] );
@N-Molham
N-Molham / helpers.php
Created March 28, 2015 00:31
Get next/previous post by entry date
<?php
/**
* Get next/preview post by post_date
*
* @param int|WP_Post $post
* @param boolean $next_post
* @return WP_Post|WP_Error
*/
function get_next_prev_post_by_date( $post, $next_post = true )
{
<?php
function my_condition( $original )
{
if ( is_numeric( $original ) )
$original = absint( trim( $original ) ) >= 2016 ? 'new' : 'used';
$makes = array(
'cons' => 'Used',
'used' => 'Used',