Easiest but powerful encryption in PHP

For a secured system, most of the data is encrypted in server end and sent to database. And after fetching the data from database, just decrypt before showing in front end. There are lots of procedure to encrypt the data, lots of encryption algorithm out there. But, here we will use a simple encryption method though it’s powerful 🙂 We are going to use mcrypt library of php for this method. You can install the library following the instruction below: (based on Ubuntu)

Continue Reading

You may also like

How to use custom post type archive as front page

We can easily set any page as front page from Settings > Reading. It can be any static page. But what if we want to set an archive or CPT archive page as front page? There are many ways to do so. We can create a custom page template, and write our code to get the posts for the post type (will look like an archive). Then create a wordpress page using that page template and select that page as front page from Settings > Reading. This is a little complex if you are not a developer. Or even if […]

Continue Reading

You may also like

How to convert hexadecimal color value to RGB value in php

Most of the CMS provides a color picker in admin panel to user to choose a color. And almost all of the color pickers return the color code as hexadecimal mode, e.g. #4EE4D3. So, you can just get the value and set the color in css. For example: [php] body{ background: } [/php] This is a very good practice. Problem occurs if you want to put a opacity option to the user. You can set background opacity with hexadecimal color value. You must use RGBA filter, so RGB color mode as well. Like: [css] body{ background: rgba(233, 122, 234, 0.7); […]

Continue Reading

You may also like

Get current page url in php

In an application, sometimes we need to get the current page URL in php. I mean, the URL shown in the browser. Here is how you can do it. First, we will declare and use the function as the following: This file contains 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 Show hidden characters <?php function current_page_url() { $url = 'http'; if ($_SERVER["HTTPS"] == "on") $url .= "s"; $url .= "://"; if ($_SERVER["SERVER_PORT"] != "80") […]

Continue Reading

You may also like

How to write dynamic css in a php file in wordpress

It’s always standard to maintain a separate css file for styling, even for dynamic css that is generated by the theme options. Most of the theme developers include this dynamic styles into the header or footer using wp_head or wp_footer hook. How’s about having a totally separate css file for the dynamic styles? It’s pretty simple so let’s start! In my example, I have used redux framework, so that I have a global variable. In my case, I assume my global variable is $lts. So, in functions.php you need to add like this: [php] // Adding custom script add_action( ‘wp_enqueue_scripts’, […]

Continue Reading

You may also like

How to load a wordpress plugin at very last

You need to load your plugin at vert last? Well, sometimes we develop a simple plugin that is dependent to other plugins, something like add-on. So, in those cases, the addon plugins need to be loaded after the parent plugin. Here is a small snippet that need to put at the addon plugin to make sure that the plugin will be load at the last of all plugins. Here you go: This file contains 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 […]

Continue Reading

You may also like

Limit one blog per user in a wordpress multisite

In a wordpress multisite, an user can create as many blog as he wants. If you Pro Sites you can control this. Pro Sites is a giant plugin that will help you to have control over the whole network. But if you just want to limit one blog per user in a wordpress multisite and don’t want to use a huge plugin like Pro Sites, then this small snippet should help you. This file contains 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 […]

Continue Reading

You may also like

Easily display member cards with WPMU DEV Membership

Here’s a simple shortcode snippet to let you easily add a membership card for your site’s members when using WPMU DEV’s Membership plugin. This was requested in the WPMU DEV forums, where we love to help members out with simple and useful custom snippets. WPMU DEV Forum topic: Display Membership Data Print/Mobile The snippet adds a [mem_card] shortcode that will then show some member details. This file contains 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 […]

Continue Reading

You may also like

How to enable php mail() in your ubuntu

In my last post I showed you how you can set up an ubuntu server for apache, php, mysql, phpmyadmin and wordpress multiste. Below is the link if you want to take a look: How to setup a VPS (Ubuntu) for WordPress hosting – A to Z tutorial Today, we will learn how we can enable email in that server, so that we can use php mail() to send mail from our system. Today I won’t go in that detail but just to set a simple mail server. The simplest way to enable mail in your ubuntu is to run […]

Continue Reading

You may also like

How to hide a plugin for non-admin users in wordpress

Today I will show how you can hide a plugin from the users that are non-admin. If you use a multisite, you can control a lots of stuffs with Pro Sites plugin. But what if you don’t want to use Pro Sites? This simple scripts will do the job for you. [php] function custom_plugins( $plugins ){ if ( !is_super_admin() ) { // Add comma separated paths of plugins that you want to hide $hide_plugins = array(‘pluginFolder/pluginFile.php’, ‘pluginFile.php’); foreach ($hide_plugins as $hide_plugin) { unset($plugins[$hide_plugin]); } } return $plugins; } add_filter(‘all_plugins’, ‘custom_plugins’); [/php] You can add those codes in your functions.php in […]

Continue Reading

You may also like