Skip to content

Instantly share code, notes, and snippets.

View mostafasoufi's full-sized avatar
🍬

Mostafa Soufi mostafasoufi

🍬
View GitHub Profile
@mostafasoufi
mostafasoufi / functions.php
Last active September 25, 2016 07:43
Comment fields position order handler
<?php
/**
* Comment fields position order handler
* @param array $form Form fields
* @author Mostafa Soufi <mostafa.soufi@hotmail.com>
* @link (http://mostafa-soufi.ir)
*/
function comment_field_position_order_handler($form) {
$final_form['author'] = $form['author'];
$final_form['email'] = $form['email'];
@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',