Skip to main content

Posts

Showing posts with the label PHP

Exclude category from wordpress default widget

If you use wordpress default widget in your theme, you will notice that you don't have an option to exclude the category. In such case you can use some plugin's and get your work done, but i prefer to use less plugins and do more of coding things. So in such case I write the below code in functions.php file located in my selected theme folder. <?php function exclude_widget_categories($args){ $exclude = "1,17"; // The IDs of the excluding categories $args["exclude"] = $exclude; return $args; } add_filter("widget_categories_args","exclude_widget_categories"); ?>

install JSON in centos

JSON (JavaScript Object Notation) is a light weight data-interchange format. yum install gcc make php-devel php-pear pecl install json vi /etc/php.ini Look for work Dynamic Extensions and add a new line extension=json.so Make sure JSON is also enable in this file cat /etc/php.d/json.ini like this. ; Enable json extension module extension=json.so service httpd restart

Installing Yii Framework in XAMPP

Yii is a component-based high-performance PHP framework. Yii provides nearly every feature needed by today's Web 2.0 application development like MVC, web services, theming, widgets and so on. 1. Download the framework from www.yiiframework.com 2. Extract the file and place it into your xampps htdocs. For this tutorial, I have extracted D:\XAMPP\htdocs\yiiframework 3. Make sure that Apache and MySQL services are running in XAMPP. 4. There is some requirement checking to be done, so browse to http://localhost/yiiframework/requirements/ 5. Make sure that you pass all the requirements and there is no Failed status. 6. Lets set system variable. Go to My Computer>Properties>Advance System Settings>Environment Variables . Under System Variables select Path variable and Edit. In Variable Value, append ;D:\xampp\php at the end of line. The reason we do this is because, if we don't set the value we get error "php.exe is not recognized as an internal or external com...

Installing Latest version of PHP on CentOS

Recently I have been trying to install the latest version of PHP in my CentOS. But before I do that, I need to install EPEL yum repository on my CentOS. EPEL for i386 http://ftp.riken.jp/Linux/fedora/epel/5/i386/epel-release-5-4.noarch.rpm EPEL for x86_64 http://ftp.riken.jp/Linux/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm If you have any version of PHP installed then you need to remove it using yum remove php php-* Now lets install Latest PHP yum install php53 php53-* After completing the installation, lets check the version of PHP installed: php -v

Using IIS and XAMPP together

I am ASP.NET developer as well as a PHP developer. I have my visual studio installed in my laptop to work on asp.net/.NET and now I need to install XAMPP to work on PHP, MySQL, Apache and Perl. By default IIS uses port 80 and 443 for HTTP and HTTPS, and Apache also uses the same ports as IIS. Now to solve the conflict of ports there is only two way: Change IIS config – the hardest way Change Apache config – the easiest way I choose to go with second option, and which is lot more easier. I installed XAMPP in my drive D: I need to configure Apache to listen to port 8080. Edit file D:/xampp/apache/conf/httpd.config Find "Listen 80" and change it to "Listen 8080" Find "ServerName localhost:80" and change it to "ServerName localhost:8080" Now I need to configure for SSL/HTTPS. Edit file D:/xampp/apache/conf/extra/httpd-ssl.conf Find "Listen 443" and change it to "Listen 4499" Find "VirtualHost _default_:443...

Warning/Deprecated Error in bbPress

After installing bbPress, if you get a Deprecated/Warning error message then please check your php Version. bbPress don't seem to support latest version of php. bbPress is doing this, has been "deprecated" (made obsolete) in the new version of PHP. Everything will still work, but in the future PHP may change and these functions will error out. Steps: 1. locate bb-load.php , go to line 25: 2. Change From error_reporting( E_ALL ^ E_NOTICE ); to error_reporting( E_ALL ^ E_DEPRECATED ^ E_NOTICE);

Changing The Site URL in bbpress

Like wordpress you can also change the Site URL of bbpress. Steps: 1. Login to phpMyAdmin. 2. Click the link to your Databases. A list of your databases will appear. Choose the one that is your bbPress database. All the tables in your database will appear on the screen. 3. From the list, look for bb_meta . Note: The table prefix of bb_ may be different if you changed it when installing. Click on the small icon indicated as Browse. A screen will open with a list of the fields within the bb_meta table. 4. Under the field meta_key , scroll down and look for uri . Click the Edit Field icon which usually is found at the far left at the beginning of the row. The Edit Field window will appear. In the input box for option_value, carefully change the URL information to the new address. Verify this is correct and click Go to save the information.

Changing the Site URL in wordpress

On the Settings > General screen in a single site installation of WordPress, there are two fields named "WordPress address (URL)" and "Site address (URL)". These are also known as the "Home" and "Site URL" settings. They are important settings, since they controls where WordPress thinks your site is located. They control the display of the URL in the admin section of your page as well as the front end, and are used throughout the WordPress code. Steps: 1. Login to phpMyAdmin. 2. Click the link to your Databases. A list of your databases will appear. Choose the one that is your WordPress database. All the tables in your database will appear on the screen. 3. From the list, look for wp_options . Note: The table prefix of wp_ may be different if you changed it when installing. Click on the small icon indicated as Browse. A screen will open with a list of the fields within the wp_options table. 4. Under the field option_name , scroll do...

Install bbPress and new theme

Download latest version of bbPress from bbpress.org . Unzip it rename it and upload in the root directory of the HTTP Directory, normally it is the directory where you put your website files and so on. After that follow the step, and it will ask you the database name, so make sure that you create one before. When you install custom theme for the bbpress, upload it in the my-templates folder, if there is no such folder then create one. The folder should be create where the file bb-config.php is located and the folder permission should be 755. Now go to the admin and activate the New Theme for freshly installed bbpress. Happy forum...

Difference Between include, include_once, require, and require_once

Every time I worked on PHP, I always used include, then later on I wanted to know the difference between include, include_once, require, and require_once. After googling I came to know the difference. include: Includes and evaluates the specified file, throwing a warning if the file can’t be found. include_once: Same as include, but if the file has already been included it will not be included again. require: Includes and evaluates the specified file (same as include), but instead of a warning, throws a fatal error if the file can’t be found. require_once: Same as require, but if the file has already been included it will not be included again.

Wordpress Hack to Hide its version

There had been issue and talk going around about wordpress sites being hacked. One main thing that most of the hackers look for is the Version of the wordpress that is being used for the site. Well if you are worried about it, here is a sweet short code that will remove the wordpress version from your source code without having to use any wordpress plugins. Open your functions.php and add the following line: remove_action('wp_head', 'wp_generator'); Open header.php and remove the following lines: <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->