Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mostafasoufi's full-sized avatar
🍬

Mostafa Soufi mostafasoufi

🍬
View GitHub Profile
@mostafasoufi
mostafasoufi / query.sql
Last active January 11, 2023 14:17
Change wordpress URLs with Mysql query
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
mostafasoufi / functions.php
Last active August 22, 2016 08:24
Wordpress post field validation (Change post status to draft if post is not complete)
<?php
/**
* Change post status to draft if post is not complete
* @param integer $post_id Post ID
* @param object $post Post Object
* @author Mostafa Soufi <mostafa.soufi@hotmail.com>
*/
function validate_post_field($post_id, $post) {
// Check post status
if( $post->post_status != 'publish' )
@mostafasoufi
mostafasoufi / functions.php
Created August 22, 2016 06:20
Modify mime type in wordpress
<?php
/**
* Modify wordpress mime types
* @param array $existing_mimes current mimes
*/
function modify_mime_type($existing_mimes){
return array_merge($existing_mimes, array(
'7z' => 'application/x-7z-compressed',
'rar' => 'package/rar',
'tar' => 'package/x-tar',