Skip to content

Instantly share code, notes, and snippets.


Mostafa Soufi mostafasoufi

Block or report user

Report or block mostafasoufi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View single.php
<?php echo wp_statistics_pages($post->ID); ?>
mostafasoufi / date_diff.php
Last active Mar 10, 2017
Get Number of days between two dates
View date_diff.php
if (!function_exists('get_days_number')) {
* Get Number of days between tho dates
* @param string $first_date First date
* @param string $second_date Second date
* @return float
function get_days_number($first_date, $second_date)
mostafasoufi / function.php
Last active May 7, 2017
Disable REST API endpoints in the WordPress
View function.php
// Removed wordpress rest endpoints
remove_action( 'rest_api_init', 'create_initial_rest_routes', 99 );
mostafasoufi / checker.php
Last active Sep 5, 2017
PHP & MySQL checker
View checker.php
* Class Service_Checker
* @author Mostafa Soufi
class Service_Checker {
* @var array
mostafasoufi / functinos.php
Last active Sep 6, 2017
Get next & previous post in WordPress
View functinos.php
* Get Next & Previous post
* @param $post_id
* @param $category_id
* @param string $taxonomy
* @return array
mostafasoufi / functinos.php
Created Sep 17, 2017
How get pages stat list with page slug
View functinos.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 / query.sql
Last active Jan 3, 2018
Change wordpress URLs with Mysql query
View query.sql
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
mostafasoufi /
Created Sep 1, 2018
Run some commands in bulk project with bash script
for i in ${array[*]}
mostafasoufi / functions.php
Last active Mar 15, 2019
Sending SMS in WordPress (Required WP-SMS plugin)
View functions.php
<form method="post" action="">
Destination number:
<input type="text" value="" name="number" required>
<textarea name="message" required></textarea>
You can’t perform that action at this time.