Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍

Mostafa Soufi mostafasoufi

🐍
View GitHub Profile
@mostafasoufi
mostafasoufi / dump.sql
Created Dec 15, 2019
Employees MySQL Database
View dump.sql
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
@mostafasoufi
mostafasoufi / print.php
Last active Dec 13, 2019
Print my name with foreach in PHP
View print.php
<?php
// TASK 1 - print out your name with one of php loops
foreach (str_split('Mostafa') as $char) {
echo $char;
}
@mostafasoufi
mostafasoufi / update.sh
Created Sep 1, 2018
Run some commands in bulk project with bash script
View update.sh
#!/bin/bash
RED='\033[0;31m'
NC='\033[0m'
array=(
"project-name1"
"project-name2"
)
for i in ${array[*]}
@mostafasoufi
mostafasoufi / functinos.php
Created Sep 17, 2017
How get pages stat list with page slug
View functinos.php
<?php
global $wpdb, $table_prefix;
$page_slug = '%about%';
$pages = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM `{$table_prefix}statistics_pages` WHERE `uri` LIKE %s", $page_slug ) );
echo '<table border="1"><tr><td>ID</td><td>Count</td><td>Slug</td></tr>';
foreach ( $pages as $page ) {
echo "<tr><td>{$page->id}</td><td>{$page->count}</td><td>{$page->uri}</td></tr>";
}
echo '</table>';
@mostafasoufi
mostafasoufi / functinos.php
Last active Sep 6, 2017
Get next & previous post in WordPress
View functinos.php
<?php
/**
* Get Next & Previous post
*
* @param $post_id
* @param $category_id
* @param string $taxonomy
*
* @return array
*/
@mostafasoufi
mostafasoufi / checker.php
Last active Sep 5, 2017
PHP & MySQL checker
View checker.php
<?php
/**
* Class Service_Checker
* @author Mostafa Soufi
*/
class Service_Checker {
/**
* @var array
*/
@mostafasoufi
mostafasoufi / functions.php
Last active Mar 15, 2019
Sending SMS in WordPress (Required WP-SMS plugin)
View functions.php
<form method="post" action="">
<label>
Destination number:
<input type="text" value="" name="number" required>
</label>
<label>
Text:
<textarea name="message" required></textarea>
</label>
View single.php
<?php echo wp_statistics_pages($post->ID); ?>
View plugin-class-demo.php
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Plugin Class Demo
* Description: How I am using the base class in plugins.
* Plugin URI:
* Version: 2012.09.29
* Author: Thomas Scholz
* Author URI: http://toscho.de
* License: GPL
* Text Domain: plugin_unique_name
@mostafasoufi
mostafasoufi / functions.php
Created Jan 4, 2017
Upload custom post type files in another folder.
View functions.php
<?php
/**
* Upload custom post type files in another folder
* @author Mostafa soufi <mostafa.soufi@hotmail.com>
*/
add_filter( 'upload_dir', function($args) {
if( !isset($_REQUEST['post_id']) ) {
return $args;
}
You can’t perform that action at this time.