0

drupal 7 interview question

1.How to Connect multiple database in drupal 7

2.How cron work in drupal 7

3.How view relation show second image if first image is empty in view without using template file.

4.How to add table in drupal 7

5.How to update table in drupal 7

6.How to create block in drupal 7

7.How many ways we can add css to drupal 7

8.How to create custom hooks in drupal 7

9.How to add form in template file in drupal 7

10.what is template file in drupal 7

11.what is prepocess in drupal 7

12.how to create template in drupal 7

13.How to connect to db

Read
0

How to Use wordpress hooks in wordpress

Hooks Allow us to manipulate data in an easy and safe way.
Two types of hooks.
1.Action Hooks:
Trigger by an event. Allow us to add our on functions to them when every we want. Used for Stuff like “when X Happens, do y”.
2.Filter Hooks:
allow us to Manipulate data. As in “take this X var,do Something in with it(“filter it”) and Return the result”.
Action Hook:
Action Hooks:trigger by an event. Allow us to add our on functions to them when every we want.Used for stuff like “when X happen,do Y”.
do_action("hook_name") //will create our hook
add_action("hook_name","Callback_function", Priority)
 
function callback_function(){
echo "Welcome to Wpdadd"
//code goes here
}
To append text to “welcome to wpdadd” We can create
add_action("hook_name","override_Callback_function", Priority)
 
function callback_function(){
echo "Bye  Wpdadd";
//code goes here
}
If we want to remove the filter we can use.
remove_action( string $tag, callable $function_to_remove, int $priority = 10 )
 
remove_action( 'hook_name', "callback_function", int $priority = 10 )
Filters
Filter Hooks:allow us to Manipulate data.As in “take this X var,do something in with it(‘filter it”) and return the results.
apply_filters($tag,$value,$var ...);
 
add_filter($tag,$function_to_add,$priority,$accepted_args);
 
function function_to_add($arg){
 
  return $arg;
}
Suppose we need to override the hooks we can use.
apply_filter('filter_name', "callback_function",$arg);
 
add_filter($tag,$function_to_add,$priority,$accepted_args);
 
function function_to_add($arg){
 
return  apply_filter('filter_name', "callback_function",$arg);
}
 
 
 
add_filter('filer_name' ,'callback_function');
 
 
function callback_function($arg){
 
 
$arg ="changed";
 
return $arg;
 
}
Suppose we need to Remove the Filters
 remove_filter( $tag, $function_to_remove, $priority );
 
remove_filter( 'hook_name', "callback_function", int $priority = 10 )
Read
0

Gridder Portpolio

We have Developed the Gridder Portpolio Plugin and Deployed in the word press plugin store here you can find the demo of http://wpdadd.com/gridder/ and you can download form WordPress Store
BY using using this Gridder portpolio you will get the same look as Google Search images and when we click on images it will expand and show the information relation to that image
Read
0

How To Use AJAX In WordPress in Three Simple Steps

Step 1:
First we need to Add JQuery Script And Need to Initial Ajax Variable Global as shown below
add_action( 'init', 'ajax_script_enqueuer' );
 
function ajax_script_enqueuer() {
   wp_register_script( "ajax_script", WP_PLUGIN_URL.'/your_plugin/script.js', array('jquery') );
   wp_localize_script( 'ajax_script', 'ajaxuse', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));        
 
   wp_enqueue_script( 'jquery' );
   wp_enqueue_script( 'ajax_script' );
 
}
Step 2:
Second we need to Handle the Ajax Request this can be using Post and Get Hooks in WordPress as shown below
add_action("wp_ajax_ajax_response", "ajax_response"); //Login 
add_action("wp_ajax_nopriv_ajax_response", "ajax_response"); //not login
 
function ajax_response() {
  $result = "welcome to Wpdadd Ajax";
    $result = json_encode($result);
      echo $result;
   die();
 
}
Step 3:
Finally we need to Trigger Ajax as shown below
jQuery('.button').click(function(){
 
     jQuery.ajax({
         type : "post",
         dataType : "json",
         url : ajaxuse.ajaxurl,
         data : {action: "ajax_response"},
         success: function(response) {
        alert('success');
         },error: function(XMLHttpRequest, textStatus, errorThrown) { 
         alert("Status: " + textStatus); alert("Error: " + errorThrown); 
    }  
      })  
 
 
  });
Read
0

How to Create Custom Get Rest Api In WordPress

The WordPress Has In build Rest Api and Also Provides End Points
To Create A Rest Api in word press are
1 :Get Methods
//End point is   : http://wpdadd.com/wp-json/api/v1/getwpdaddstaff
 
add_action( 'rest_api_init', function () {
 
 
    register_rest_route( 'api', '/v1/getwpdaddstaff', array(
 
 
        'methods' => 'GET',
 
 
        'callback' => 'wpdaddStuff',
 
 
    ));
 
 
});
 
 
function wpdaddStuff( $request ) {
 
 
 return   'Welcome to Wpdadd'  ;
 
 
 
 }
//ouput be
Welcome to Wpdadd
2 – Passing one of number parameter to Get Method
 
//Endpoint  http://wpdadd.com/wp-json/api/v1/get/wpdadd/{number}
 
 
 
add_action( 'rest_api_init', function () {
 
 
    register_rest_route( 'api', '/v1/get/wpdadd/(?P<id>\d+)', array(
 
 
        'methods' => 'GET',
 
 
        'callback' => 'wpdaddStuff',
 
 
    ));
 
 
});
 
 
 
 
 
function wpdaddStuff( $request ) {
 
 
 return   $request['id']  ;
 
 
 }
4 – Passing multiple parameters of combination of number and alphabet using get method
 
//Endpoint : http://wpdadd.com/wp-json/api/v1/getwp/{parameter 1}/{parameter2}
 
 
 
 
 
add_action( 'rest_api_init', function () {
 
 
    register_rest_route( 'api', '/v1/getwp/(?P<param1>[a-z0-9\-]+)/(?P<param2>[a-z0-9\-]+)', array(
 
 
        'methods' => 'GET',
 
 
        'callback' => 'wpdaddStuff',
 
 
    ));
 
 
});
 
 
 
 
 
function wpdaddStuff( $request ) {
 
 
 
 
 
 return $request['param1']." ".$request['param2'];
 
 
}
Read
0

How to Add www to URL in Wordpreess or php Using Htaccess

ou have a Web Site Called Wpdadd.com and When user try to access you website without www you need to append www at the Domain or if the user is access you page example : wpdadd.com/contact this page need to add www.wpdadd.com/contact follow the below steps
go to .htaccess find RewriteEngine on the added below for Redirecting non-www to www url
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Read
0

How to add thumbnail or Image for Beaver Builder Custom Template

When we Create A custom Template In the Beaver Builder .We are not able to Add Custom Thumbnail For that Templates.
By Default Beaver Builder Uses Feature Image of template as a Thumbnail and Featured Image is Hidden in Beaver Builder .
Beaver Builder Uses a Post type “fl_builder_register_template_post_type_args” .If you check the core files in there are using apply filter .
BY Using the Apply Filter we can add Extra Parameter As “thumbnail” Under supports array below is the syntax how we can add.
add_filter('fl_builder_register_template_post_type_args','filter_thumbnail');
function filter_thumbnail($args){
    $args['supports'][] ='thumbnail';
    return $args;
}
Place the Above Code in Function.php or create a plugin and place the Code
After Placing You can Go to Template tab and Create or edit the template and set the featured image .
Read
0

How to Enable WordPress debug and Log error on debug.log

As we Know By Using the Debug We can Solve Any problem in PHP.  The WordPress Also Support the Debugging Concept.To debug we need to enable the Debug First in PHP. The Same Thing is Apply in WordPress because WordPress is the Cms Based on PHP.To Enable the Debug we need to Follow the Following steps.
Step 1 Go to wp-config.php
Find
define('WP_DEBUG', false);
in wp-Config.php as shown in the below image

Change
define('WP_DEBUG', false)
to
define('WP_DEBUG', true)
and under this past this code
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', true);
Step 3: Go wp-content
And Check debug.log file under wp-content is available or not if not available create file called debug.log
as shown in the below

Whatever the Error we get all the error is going to log in debug.log
Suppose if we need to add custom error in the debug.log we need to use predefined  function called
error_log("You log message");

By using the above function it will log in debug.log as shown below
Read

About Me

My photo

HI i am mohammed  a Embedded Software Developer ,SEO specialist,Electronic engineer   Read more

ads