Browsing Category

Wordpress Developer

Wordpress Developer

Change PHP configuration options without editing php.ini

January 2, 2018

PHP options is usually already configured at the server of your website. In many cases, the PHP configurations is set up with limited numbers that will not fit and meet your needs. For example, you can change the upload max size to increase the file size that you want to upload or the max execution time to run a script.

Normally, all of PHP settings are located in php.ini file of PHP directory on your server. However, in most cases if you are on shared host, you will not be able to find and edit this php.ini file.

Changing PHP configurations is necessary to extend that limit. And to change the PHP configuration, the easiest way is to contact the hosting service provider for support. In addition, you also can change the PHP configuration by one of three ways below.

1. Edit Theme Functions file

Some cases will be solved easily by using ini_set function to set PHP configuration from theme function file by this syntax.

@ini_set( '{option_name}' , '{value_to_set}' );

For example, if you want to change the upload_max_filesize to 64M, the completed syntax would be like this

@ini_set( 'upload_max_size' , '64M' );

Note : Not all the available options can be changed using ini_set(). There is a list of all available options in the appendix.

2. Edit htaccess file

In the root directory, you can find .htaccess file easily. And you can use this syntax to change the PHP configuration options.

php_value {option_name} {value_to_set}

For example, if you want to change the upload_max_filesize to 64M, the completed syntax would be like this

php_value upload_max_filesize 64M

And please note that these tricks may not work in some cases which hosting provider doesn’t allow to override the PHP configuration options. Then you need to contact your web hosting providers to get these changes.

Wordpress Developer

How to use Autocomplete param type in Visual Composer

December 19, 2017

The parameter Autocomplete suggests for you: post, page, custom post type, categories, custom taxonomies by your keywords.
So you can select which one you need easily. By default, you usually use in Post Grid Shortcode, Post Masonry Shortcode
Autocomplete in Visual Composer Post Grid Shortcode Autocomplete in Post Masonry Shortcode

And if you want to use this Autocomplete param type in your shortcode, please follow some steps below:

1. Create Function to gell post result by suggested keyword or post id:


function felis_blog_post_autocomplete_suggester( $query) {
global $wpdb;
$post_id = (int) $query;
$post_results = $wpdb->get_results( $wpdb->prepare( "SELECT a.ID AS id, a.post_title AS title FROM {$wpdb->posts} AS a
WHERE a.post_type = 'post' AND a.post_status != 'trash' AND ( a.ID = '%d' OR a.post_title LIKE '%%%s%%' )", $post_id > 0 ? $post_id : - 1, stripslashes( $query ), stripslashes( $query ) ), ARRAY_A );
$results = array();
if ( is_array( $post_results ) && ! empty( $post_results ) ) {
foreach ( $post_results as $value ) {
$data = array();
$data['value'] = $value['id'];
$data['label'] = $value['title'];
$results[] = $data;
}
}
return $results;
}

2. Add function in step 1 to vc_autocomplete posts_callback filter:

add_filter( 'vc_autocomplete_felis_content_slider_2_posts_callback', 'felis_blog_post_autocomplete_suggester', 10, 1 );

felis_content_slider_2 is your shortcode base name.

3. Create function render result in step 1:


function felis_post_autocomplete_suggester_render( $query ) {
$query = trim( $query['value'] );

    // get value from requested
if ( ! empty( $query ) ) {
$post_object = get_post( (int) $query );
if ( is_object( $post_object ) ) {
$post_title = $post_object->post_title;
$post_id = $post_object->ID;
$data = array();
$data['value'] = $post_id;
$data['label'] = $post_title;
return ! empty( $data ) ? $data : false;
}
return false;
}
return false;
}

4. Add function in step 3 to vc autocomplete posts render:

add_filter( 'vc_autocomplete_felis_content_slider_2_posts_render', 'felis_post_autocomplete_suggester_render', 10, 1 );

felis_content_slider_2 is your shortcode base name.

In conclusion, you can use Autocomplete param type in your shortcode like this:
Autocomplete in Felis Content Slider 2 Shortcode