How to Change WordPress Themes From the Database

How to Change WordPress Themes From the Database

Sometimes it becomes necessary to manually change your theme directly from the database instead of via the WordPress admin. This is actually what we use when upgrading our admin demos since it’s much faster using the command prompt or phpMyAdmin

Some times when we change or install new theme in our wordpress site or blog. We are getting error and our site is down due to new themes installation. if we change current selected theme to any other theme then our site is working. at this situation we don’t access our front end and backend. So we have only one method to change active theme from database.

To change current active theme There are three option_name in the database that need to be changed. That is control which theme is currently active on your website.

template The Theme Name as defined in style.css
stylesheet Name of your stylesheet, which is same as theme name
current_theme Name of your theme folder

Step 1: To change the aboue required details or column value we need to write a SQL query. Access your site database from phpmyadmin or command base and write a query.

change_theme1

Chnage the table prefix which are using in your database setting. like we are using wp_tablename

when we run aboue query in in phpmyadmin we are getting there recored as a response data from executtion of the sql query. Below is the response data image.

Step 2: Now we update thse record from over new theme which we want to use(priviously working). Like we are change from the wordpress default theme “twentyfifteen”.

UPDATE wp_options SET option_value = ‘twentyfifteen’ WHERE option_name = ‘template';
UPDATE wp_options SET option_value = ‘twentyfifteen’ WHERE option_name = ‘stylesheet';
UPDATE wp_options SET option_value = ‘twentyfifteen’ WHERE option_name = ‘current_theme';

change wordpress theme from database

Step 3: After update thse three record now access your website and referesh(ctr F5) the url. you can see your site is working with “twentyfifteen” theme and you have changed your theme from database.

Call to undefined function curl_init() in PHP

Some time when we are using any php extension function we are getting “Fatal error: Call to undefined function imap_open() in PHP” or “Fatal error: Call to undefined function curl_init() in PHP” and any other Php library function.

This problem is arise when we are not enable extension(like CURL,GD extension and IMAP) and used function from these library. and due to some new and old core php function which are depreciated in and not supported in your current php version. Then we are getting these type of error.

If you are getting “Fatal error: Call to undefined function curl_init() in PHP”: It means CURL extension is not enabled on your server. To remove these type of sever required to enabled curl extension on your server.

To Enabled curl on Your Server
After enbled curl on your server.Kindly restrat apache server and refresh the application, Now your code is working fine.

If you are getting “Fatal error: Call to undefined function imap_open() in PHP”: It means IMAP extension is not enabled on your server. IMAP extension default is deactivated in XAMPP.To remove these type of sever required to enabled IMAP extension on your server.

To Enabled IMAP on Your Server Follwing below steps.

  1. Go To \xampp\php\php.ini on your server.
  2. Open your php.ini file on your feavrate editor.
  3. To activate the IMAP exstension find “extension=php_imap.dll” line in “php.ini” file and remove the beginning semicolon from the line “;extension=php_imap.dll”.
  4. Don’t forgot to Restart the Apache server, without Restarting Apache server your changes not impact.
  5. Kindly Restart Apache server and refresh the application, Now your code is working fine.

How to check function exists in php

How to check function exists in php

function_exists(): If you are using function that is not the part of the core Php function. It is the part of extra library and extension like as Curl extension, IMAP extension and rewrite modules to use these type of function, we required to enable an extension from Php ini file. function_exists is a Php inbuilt function and return TRUE if the given function has been defined otherwise return FALSE. we can use function_exists for Inbuilt and user defined function to check the function existence.

function_exists takes a function name as a parameter, and returns true if that function is available for use.

syntax: bool function_exists ( string $function_name )

Example: To check the curl_init function is available or not for using. If curl is enables on server from php.ini file then function is exists otherwise not.

AngularJS Directive

AngularJS Directive

A AngularJS directive is a function that is attached with DOM elements. Using Angular Directives, we can bind data to HTML using an expression. All AngularJS directives have a prefix with the ng namespace, used to extend HTML element attributes. Directives have the ability to execute methods, define behavior, attach controllers and DOM manipulations.

Directive Description
ng-bind: It is an alternative to {{ }} template.
ng-bind-template: used to binds multiple expressions to the view.
ng-non-bindable: used to tells Angular not to compile or bind the contents of the current DOM element.
ng-bind-html: used to bind inner HTML property of an HTML element.
ng-change: used To change in the input value causes a new value to be committed to the model.
ng-csv: Directive that is used to turns arrays and objects into downloadable CSV files.
ng-checked: used to checked checkbox.
ng-class: Used to set CSS classes dynamically on an HTML element
ng-cloak: used to prevent displaying the html template,until AngularJS has taken control.
ng-click: Used to execute a method or expression when element is clicked.
ng-controller: used to attached a controller class to the view.
ng-disabled: used to disabled attributes to the form element.
ng-form: HTML does not allow nesting of form elements. It is useful to nest form.
ng-file : upload Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support
ng-grid: used forAngular Data Grid
ng-href: used to bind AngularJS variables to the href attribute.
ng-include: used to fetch, compile and include an external HTML fragment to your page.
ng-if: directive Used to removes and recreates a portion of the DOM tree.
ng-init: used to set the default variable value.
ng-switch: used to conditionally switch control based on matching expression.
ng-sortable: AngularJS Library used for Drag and Drop, used for sortable and draggable and supports for Touch devices.
ng-tasty: A lightweight AngularJS tasty collection of reusable UI components
ng-table: Ttable with sorting and filtering in AngularJS
ng-like: AngularJS like bar directive
ng-model: used to bind an input,select, textarea etc elements with model property.
ng-readonly: used to set readonly attribute to an element.
ng-required: used to adds the required validator to ngModel

ng-Option: used to generate a list of
ng-repeat: used to loop through each item in collection to create a new template.
ng-selected: used to set selected option in
ng-show: It workes based on expression, if true then the element is shown or hidden respectively.
ng-hide: It workes based on expression, if true then the element is shown or hidden respectively.
ng-src: Used to bind AngularJS variables to the src attribute dynamically.
ngSelected: Sets the selected attribute on the element, if the expression inside ngSelected is truth.
ng-submit: Used to bind angular expressions to onsubmit events.
ng-pattern: ngPattern adds the pattern validator to ngModel, and used to text based input validate.

Search Elements in Multidimensional Array in Php

Search Elements in Multidimensional Array in Php

In Php there is no one built in function to search any element in Multidimensional Array, we can write own function using recursive procedure.We have create a Simple recursive function to search value in multidimensional array in php.This function returns key of the matched given value if it is in the array.

let Multidimensional array is given below

Example to find element in this array

Method 1:

let write this array in php

$array = array(‘0′ => array(‘id_order_state’ => 19),’1′ => array(‘id_order_state’ => 10),’2′ => array(‘id_order_state’ => 16));

and find element(19,11,16) assign in a veriable

And the Oupot is:

or we can write function below

Alpha Numeric with seprater Sorting in MySQL

Alpha Numeric with seprater Sorting in MySQL

Today i will explain how to sort the Aplhanumeric(alphabets and Numeric mixed) values in Mysql database.First we have create a Employee table to demonstrate the mixed sorting.

Create Employee table

TRUNCATE TABLE employee;

Insert New mixed data having in same manner

Now to short the Mysql table data string(combination og alphabet and number with hyphen just like A-1,A-8,A-3,B-2,B-25).We write below maintain query

Alpha Numeric Sorting in MySQL

Alpha Numeric Sorting in MySQL

Today i will explain how to sort the Aplhanumeric(alphabets and Numeric mixed) values in Mysql database.First we have create a Employee table to demonstrate the mixed sorting.

Create Employee table

Insert mixed data having in same manner

Now to short the Mysql table data, Like as 1,2b,60b,3c,70d,8a run below query

Features of AJS

Following are most important core features of AJS

Data-binding: Data binding means that when an element is changed in the user interface, the underlying data model is also changed.and two way binding if Data model is changed, the UI element is also changed.

Scope: Scope is nothing but an object that act as a glue between View and Controller. They hold the Model data that we need to pass to view. Scope uses Angular’s two way data binding to bind model data to the view.

Components: Modules are logical entities and responsible for maintaining your app data. if your application have sevral modules than each modules have a separate logical entity.

Services: AngularJS come with several built-in services for example $http to make a XMLHttpRequests. These are singleton objects which are instantiated only once in app.

Filters: A filter format the value of an expression for display to the user.Select a subset of items from array and returns it as a new array.

Directives: Directives are markers on DOM elements (DIV, HTML, BODY,attributes and css), and used to create custom HTML tags that serve as new, custom widgets. AngularJS has built-in directives (ngBind, ngModel)

Templates: These are the rendered view with information from the controller and model.

Routing: − It is the concept of switching views.

Model View Controller: MVC is a design pattern for dividing an application into different parts (called Model, View and Controller), each with distinct responsibility.

Model :It is responsible for maintaining data.In below example we use $scope is an object, user is a variable which is added to scope object.

View: It is responsible for display data to the user.or we can say view is the DOM elements which is used to display data.

Controller: Controller is the place where we put our application logic and used model to get the data and send it to the view for user interaction.Controller is formed simply java script classes where we declare over action for particular task.

Dependency Injection : Dependency Injection (DI) is a software design pattern that deals with how components get hold of their dependencies.

How to Use AJS.

How to Use AJS?

To use AngularJS Framework first include AnngularJS library files in your web Pages.You can used directly from google server and can be download and used from your local repository.
You can download AngularJs Library from Here for all version of Angular Js.
and you can include directly use AngularJS (CDN), to include below file in your Page.

AngularJS Tutorial

AngularJS Tutorial

AngularJS: AngularJS is a JavaScript framework developed in 2009 by Misko Hevery and Adam Abrons. or we can say AngularJS is a java script library written in JavaScript like as jquery. AngularJS extends HTML with new attributes, easy to learn and used adding behavior to your HTML and speeding up your application’s responsiveness. AngularJS introduce new attributes to extend the HTML controls features.

AngularJS referred to Angular or Angular.js. AngularJS is an open-source web application framework maintained by Google to developing Single Page Application (SPA). It aims to simplify both the development and the testing of such applications by providing a framework for client-side model–view–controller (MVC) architectures, along with components commonly used in rich Internet applications.It is licensed under the Apache license version 2.0.