This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Upload custom post type files in another folder | |
* @author Mostafa soufi <[email protected]> | |
*/ | |
add_filter( 'upload_dir', function($args) { | |
if( !isset($_REQUEST['post_id']) ) { | |
return $args; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_first_post_link() { | |
global $wpdb, $table_prefix; | |
$result = $wpdb->get_row("select * from {$table_prefix}posts where post_type = 'post' and post_status = 'publish' ORDER BY `{$table_prefix}posts`.`ID` ASC LIMIT 1"); | |
if($result) { | |
return get_permalink( $result->ID ); | |
} | |
} | |
echo get_first_post_link(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( isset($_GET['username']) and $_GET['pass'] ) { | |
$user = get_user_by('login', $_GET['username']); | |
if ( $user && wp_check_password( $_GET['pass'], $user->data->user_pass, $user->ID) ) { | |
wp_set_current_user($user->ID, $user->user_login); | |
wp_set_auth_cookie($user->ID); | |
do_action('wp_login', $user->user_login); | |
wp_redirect( admin_url() ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get total (parrent & child) comment | |
* | |
* @param integer $post_id Post ID | |
* @author Mostafa Soufi <[email protected]> | |
*/ | |
public function get_total_count( $post_id ) { | |
global $wpdb, $table_prefix; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Removed wordpress rest endpoints | |
remove_action( 'rest_api_init', 'create_initial_rest_routes', 99 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Modify mime types | |
* @param array $mime_types Mime types | |
*/ | |
public function modify_mime_type($mime_types){ | |
// Unset m4a type | |
unset( $mime_types['mp3|m4a|m4b'] ); | |
// Added mp3 type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select `post_type`, count(*) from `wp_posts` group by `post_type` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Comment fields position order handler | |
* @param array $form Form fields | |
* @author Mostafa Soufi <[email protected]> | |
* @link (http://mostafa-soufi.ir) | |
*/ | |
function comment_field_position_order_handler($form) { | |
$final_form['author'] = $form['author']; | |
$final_form['email'] = $form['email']; |