WPMobile.App Shortcodes

Below, you’ll find a detailed guide on how to add the WPMobile.App — Android and iOS Mobile Application Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the WPMobile.App — Android and iOS Mobile Application Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the WPMobile.App — Android and iOS Mobile Application Plugin and the shortcodes it provides:

Plugin Icon
WPMobile.App — Android and iOS Mobile Application

"WPMobile.App — Android and iOS Mobile Application is a powerful WordPress plugin that enables you to convert your website into a mobile app. It's compatible with both Android and iOS platforms."

★★★★☆ (146) Active Installs: 5000+ Tested with: 6.2.3 PHP Version: 5.6
Included Shortcodes:
  • [wpappninja_push_config]
  • [wpapp_date]
  • [wpapp_login]
  • [wpapp_lang_selector]
  • [wpapp_category]
  • [wpapp_tags]
  • [wpapp_ads]
  • [wpapp_push]
  • [wpapp_config]
  • [wpapp_search]
  • [wpapp_image]
  • [wpapp_image_small]
  • [wpapp_author]
  • [wpapp_comment_number]
  • [wpapp_title]
  • [wpapp_title_main]
  • [wpapp_comment]
  • [wpapp_excerpt]
  • [wpapp_similar]
  • [wpapp_social]
  • [wpapp_share]
  • [wpapp_history]
  • [wpmobile_qrcode_2]
  • [wpmobile_qrcode]
  • [wpapp_qrcode]
  • [wpmobileapp_author]
  • [wpmobileapp_date]
  • [wpmobileapp_category]
  • [wpapp_home_configure]
  • [wpapp_home]
  • [wpapp_recent]
  • [wpapp_welcome]
  • [wpmobile_notification_badge]

WPMobile.App [wpappninja_push_config] Shortcode

The WPAppNinja shortcode is a WordPress plugin that manages push notification settings. It enables users to select which categories they want to receive notifications from. The shortcode checks if the user has push notifications enabled. If not, it displays a message and a button to enable them. If enabled, it fetches the user’s current settings and displays a form with category checkboxes. The user can select categories and save their preferences. The changes are then updated in the database.

Shortcode: [wpappninja_push_config]

Examples and Usage

Basic example – The following code will enable the shortcode to activate the push configuration function in WPAppNinja plugin.

[wpappninja_push_config /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpappninja_push_config] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpappninja_push_config', 'wpappninja_push_config' );

Shortcode PHP function:

function wpappninja_push_config() {

	global $wpdb;

	$user_bdd_id_check = $wpdb->get_row($wpdb->prepare("SELECT `user_id` FROM {$wpdb->prefix}wpappninja_push_perso WHERE `id` = %s", $_COOKIE['HTTP_X_WPAPPNINJA_ID']));

	if (!isset($user_bdd_id_check->user_id) || !isset($_COOKIE['HTTP_X_WPAPPNINJA_ID'])) {
		$html = "<p><b style='color:darkred'>" . __('Push notifications are disabled.', 'wpappninja') . "</b></p>";
		$html .= '<p><a style="padding: 14px;border-radius:5px;line-height: initial;border:1px solid '.wpappninja_get_hex_color().';color:'.wpappninja_get_hex_color().';text-transform:uppercase;margin: 15px auto 25px;height: auto;display: inline-block;background:white" class="button" href="?wpapppushconfig=1">' . __('Enable push notifications', 'wpappninja') . '</a></p>';
		return $html;
	}


	$category = array_filter( explode(',', get_wpappninja_option('push_category', '')));
	$user_id = $_COOKIE['HTTP_X_WPAPPNINJA_ID'];


	$html = '<!-- Push settings -->';

	if (isset($_POST['enablewpapppush'])) {
		$user_category = "";
		if (is_array($_POST['wpapp_category'])) {
			$user_category = implode(',', $_POST['wpapp_category']);
		}

		$wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}wpappninja_push_perso SET `category` = %s WHERE `id` = %s", $user_category, $user_id));

		$html .= '<p style="background: #348734;text-align:center;color:white;padding: 10px 0;text-transform: uppercase;font-weight: 700;">' . __('Settings saved', 'wpappninja'). '</p>';
	}

	$user_settings = $wpdb->get_row($wpdb->prepare("SELECT `category` FROM {$wpdb->prefix}wpappninja_push_perso WHERE `id` = %s", $user_id));

	$html .= '<p><a style="padding: 14px;border-radius:5px;line-height: initial;border:1px solid '.wpappninja_get_hex_color().';color:'.wpappninja_get_hex_color().';text-transform:uppercase;margin: 15px auto 25px;height: auto;display: inline-block;background:white" class="button" href="?wpapppushconfig=1">' . __('Enable push notifications', 'wpappninja') . '</a></p>';

	if (count($category) > 0) {

		$html .= '<form action="" method="post">
		<h3>'.__('Subscriptions', 'wpappninja').'</h3>
		<input type="hidden" name="enablewpapppush" value="1" />
		<div class="list-block">';

		foreach ($category as $c) {

			$c = trim($c);

    		$html .= '<label class="label-checkbox item-content">
	   	    	<input type="checkbox" name="wpapp_category[]" value="' . $c . '" ';

	    	    if (preg_match('#' . $c . '#', $user_settings->category)) {$html .= 'checked';}

	    	    $html .= ' /> ' . $c . '
   			</label>
   			<br/>';

		}
	
		$html .= '</div><br/><input type="submit" style="color:white;background:'.wpappninja_get_hex_color().'" class="button" value="' . __('Save', 'wpappninja') . '" /></form>';
	}

	return $html;
}

Code file location:

wpappninja/wpappninja/inc/api/read_enhanced.php

WPMobile.App [wpapp_date] Shortcode

The WPAppNinja shortcode is a custom function that displays the date of a post in a human-readable format. It retrieves the current post’s date, calculates the time difference from the current time, and presents it in an easy-to-understand manner.

Shortcode: [wpapp_date]

Examples and Usage

Basic example – The shortcode ‘[wpapp_date]’ displays the date of the current post in a human-readable format. It doesn’t require any parameters, making it simple to use.

[wpapp_date /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_date] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_date', 'wpapp_date' );

Shortcode PHP function:

function wpapp_date() {

	$content_post = get_post();
	
	return '<!-- Date -->
	<p class="wpappninja_date">' . wpappninja_human_time(current_time('timestamp') - strtotime($content_post->post_date)) . '</p>';
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_login] Shortcode

The WPappninja shortcode is designed to facilitate user login and registration. It displays an interactive form for inputting user credentials. The shortcode works by checking if a user is logged in or not. If not, it provides options to either login or register, if user registration is enabled. It also includes error handling for failed login attempts, displaying appropriate error messages. If a user is already logged in, it displays their avatar, username, and a logout option. The shortcode is flexible and can be easily integrated into your WordPress site.

Shortcode: [wpapp_login]

Examples and Usage

Basic Example – Display a login form using the wpapp_login shortcode.

[wpapp_login /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_login] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_login', 'wpapp_login' );

Shortcode PHP function:

function wpapp_login() {

    if (isset($_GET['login']) && $_GET['login'] == 'fail') {
        echo '<script>
        jQuery(function(){
            app.popup.open(jQuery(\'.popup-login\'));
        });
        </script>';
                           
        if (isset($_GET['reason'])) {
                           
                           $errormsg = esc_js($_GET['reason']);
                           
                           if ($errormsg == "both_empty") {$errormsg = __('Email and password are both required', 'wpappninja');}
                           if ($errormsg == "incorrect_password") {$errormsg = __('Password is incorrect', 'wpappninja');}
                           if ($errormsg == "invalid_username") {$errormsg = __('Username doesnt exist', 'wpappninja');}

                           echo '<script>
                           jQuery(function(){
                                  app.dialog.alert(\''.$errormsg.'\', \''.__('Something is wrong', 'wpappninja').'\');
                           });
                           </script>';
        }

        echo '<style>form#loginform input[type="text"], form#loginform input[type="password"] {border: 2px solid #c84848;}</style>';
    }

	ob_start();

    if (!is_user_logged_in()) {

        echo '<div class="wpmobile-login-loggedin">
        <div class="wpmobile-login-avatar">';
        echo get_avatar( "", 90 );
        echo '</div>';

    	echo '<p><input data-popup=".popup-login" type="button" class="popup-open button panel-close" style="width:100%" value="'.__('Login', 'wpappninja').'" /></p>';
    	if ( get_option( 'users_can_register' ) ) {
    	echo '<p><input data-popup=".popup-register" type="button" class="popup-open button panel-close" style="width:100%" value="'.__('Register', 'wpappninja').'" /></p>';
    	}
        do_action('wpmobile_after_login');
    	echo '</div>

    	<style>p.login-remember {display: none;}</style>

    	<div class="popup popup-reset">
    	<div class="block" style="background:white">
    	        <div class="wpmobile-login-avatar">';
        echo get_avatar( "", 90 );
        echo '</div><br/>
    	<form name="registerform" id="registerform" action="" method="post">
			<input type="hidden" name="resetwpmobileapp" value="1" />
			'.wp_nonce_field( 'resetwpmobileapp' ).'		
			<p class="login-username">
				<label for="uemail">'.__('Email', 'wpappninja').'</label>
				<input style="width: 100%;padding: 10px;background: #fff;border: 1px solid #eee;" type="email" name="uemail" id="wpmobileresetmail" class="input input-with-value" value="" size="20">
			</p>
			<p class="login-submit">
				<input type="submit" name="wp-submit" class="button button-primary" value="'.__('Send reset link', 'wpappninja').'">
			</p>
			
		</form><br/>
        <p style="font-size:0.8em;text-align:center;color:gray"><span data-popup=".popup-reset" class="popup-close">' . __('cancel', 'wpappninja') . '</span></p>
        </div>
        </div>


    	<div class="popup popup-login">
    	<div class="block" style="background:white">
    	        <div class="wpmobile-login-avatar">';
        echo get_avatar( "", 90 );
        echo '</div><br/>';
        wp_login_form(array('redirect' => wpappninja_cache_friendly(wpmobile_weglot(wpappninja_get_home()))));
        echo '<br/>
        <a href="#" class="button" onclick="app.popup.close(jQuery(\'.popup-login\'));setTimeout(function(){app.popup.open(jQuery(\'.popup-reset\'));}, 300)"><i class="icon icon-lock"></i> ' . __('Password lost?', 'wpappninja') . '</a>
        <br/><br/>
        <p style="font-size:0.8em;text-align:center;color:gray"><span data-popup=".popup-login" class="popup-close">' . __('cancel', 'wpappninja') . '</span></p>
        </div>
        </div>

    	<script>jQuery(function(){jQuery(\'#rememberme\').attr(\'checked\', true);});</script>';

        if ( get_option( 'users_can_register' ) ) {

    	echo '<div class="popup popup-register">
    	<div class="block" style="background:white">
    	        <div class="wpmobile-login-avatar">';
        echo get_avatar( "", 90 );

    $__user = ( isset($_POST['uname']) ? $_POST['uname'] : '' );
    $__email = ( isset($_POST['uemail']) ? $_POST['uemail'] : '' );


        echo '</div><br/>


			<form name="registerform" id="registerform" action="" method="post">
			<input type="hidden" name="registerwpmobileapp" value="1" />
			'.wp_nonce_field( 'registerwpmobileapp' ).'
			<p class="login-username">
				<label for="uanme">'.__('Username', 'wpappninja').'</label>
				<input style="width: 100%;padding: 10px;background: #fff;border: 1px solid #eee;" type="text" name="uname" class="input input-with-value" value="'.$__user.'" size="20">
			</p>			
			<p class="login-username">
				<label for="uemail">'.__('Email', 'wpappninja').'</label>
				<input style="width: 100%;padding: 10px;background: #fff;border: 1px solid #eee;" type="email" name="uemail" class="input input-with-value" value="'.$__email.'" size="20">
			</p>

			<p class="login-username">
				<label for="upass">'.__('Password', 'wpappninja').'</label>
				<input style="width: 100%;padding: 10px;background: #fff;border: 1px solid #eee;" type="password" name="upass" class="input input-with-value" value="" size="20">
			</p>
		

			<p class="login-submit">
				<input type="submit" name="wp-submit" class="button button-primary" value="'.__('Register', 'wpappninja').'">
			</p>
			
		</form>';

        echo '<br/>
        <p style="font-size:0.8em;text-align:center;color:gray"><span data-popup=".popup-register" class="popup-close">' . __('cancel', 'wpappninja') . '</span></p>
        </div>
        </div>';
    	}

    } else {
        $current_user = wp_get_current_user();

        echo '<div class="wpmobile-login-loggedin">
        <div class="wpmobile-login-avatar">';
        echo get_avatar( $current_user->user_email, 90 );
        echo '</div>';
        echo '<div class="wpmobile-login-username">';
    	echo $current_user->display_name . '</div>';
	    echo '<div class="wpmobile-login-action">';

        if (get_wpappninja_option('speed_trad') == 'manual') {
            echo '<a class="button" href="'.wp_logout_url(wpappninja_cache_friendly(wpappninja_translate(wpappninja_get_home()))).'">' . __('Logout', 'wpappninja') . '</a>';
        } else {
            echo '<a class="button" href="'.wp_logout_url(wpappninja_cache_friendly(wpmobile_weglot(wpappninja_get_home()))).'">' . __('Logout', 'wpappninja') . '</a>';
        }
                                         
	    echo '</div></div>';

    }

    return '<!-- Login -->' . ob_get_clean();
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_lang_selector] Shortcode

The wpappninja shortcode is a language selector for WordPress mobile apps. It generates a clickable flag icon, allowing users to switch languages on the site. This shortcode retrieves the current site language, lists available languages, and creates a switcher panel. Users click on their preferred language flag, triggering a site reload in the selected language.

Shortcode: [wpapp_lang_selector]

Examples and Usage

Basic example – A simple way to use the wpapp_lang_selector shortcode is to directly include it in your post or page. This will display a language selector with available languages for your website.

[wpapp_lang_selector]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_lang_selector] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_lang_selector', 'wpapp_lang_selector' );

Shortcode PHP function:

function wpapp_lang_selector() {

	$locale = wpappninja_get_lang("long");

	$html = '<!-- Locale Switch -->';

	$langs = wpappninja_available_lang();
	$locale_n = $locale;
	$k = substr($locale, 0, 2);
	
	foreach ( $langs as $l => $ll) {
		if ($ll == $k) {
			$locale_n = $l;
		}
	}

	$html .= '<p><span style="padding: 15px 0;line-height: initial;margin: 15px 0;height: auto;" onclick="wpmobile_locale_switcher.open();" class="panel-close button"><img src="'.WPAPPNINJA_ASSETS_IMG_URL.'flags/'.$k.'.gif" /> ' . wpmobile_get_nativename($k) . '</span></p>';


	$html .= '<script>
    var wpmobile_locale_switcher = "";
    jQuery(function() {
        wpmobile_locale_switcher = app.actions.create({
        buttons: [';
        foreach ($langs as $n => $l) {
            $html .= '{
              text: \'<img src="'.WPAPPNINJA_ASSETS_IMG_URL.'flags/'.$l.'.gif" /> '.wpmobile_get_nativename($l).'\',
              onClick: function () {
                document.location = \''.get_bloginfo('url') . '/' . '?redirect='.base64_encode((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']).'&WPMOBILE_LOCALE='.$l.'&rand='.uniqid().'\';
              }
            },';
        }
        
        $html .= '{
            text: \''.__('Cancel', 'wpappninja').'\',
            color: \'red\',
        },';
        $html .= ']
        });
    });
    </script>';
	
	return $html;
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_category] Shortcode

The wpappninja shortcode ‘wpapp_category’ is designed to display the category of a post in a unique style. Upon execution, it fetches the categories associated with the current post. If categories exist, it formats each category name within a styled div element, creating a visually appealing tag-like display. If no categories are found, the function returns nothing, ensuring a clean output. This shortcode enhances the user interface by representing post categories in an organized and stylish manner.

Shortcode: [wpapp_category]

Examples and Usage

Basic example – Displays the categories related to a particular post using the ‘wpapp_category’ shortcode.

[wpapp_category]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_category] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_category', 'wpapp_category' );

Shortcode PHP function:

function wpapp_category() {

	$tags = "";
	$posttags = get_the_category();
	if ($posttags) {
	  foreach($posttags as $tag) {
	    //$tags .= '<a href="' . get_category_link($tag->term_id) . '">';
	    $tags .= '<div class="chip"><div class="chip-label">' . $tag->name . '</div></div>';
	    //$tags .= '</a>'; 
	  }
	}

	if ($tags == "") {
		return;
	}

	return '<!-- Category -->
	<div class="wpmobile-category">' . $tags . '</div>';
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_tags] Shortcode

The WPAppNinja shortcode ‘wpapp_tags’ is designed to display all the tags associated with a post. The PHP function ‘wpapp_tags’ fetches the tags of a post and formats them in a div. If there are no tags, it simply returns nothing.

Shortcode: [wpapp_tags]

Examples and Usage

Basic example – A simple usage of the wpapp_tags shortcode to display the tags of a post.

[wpapp_tags]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_tags] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_tags', 'wpapp_tags' );

Shortcode PHP function:

function wpapp_tags() {

	$tags = "";
	$posttags = get_the_tags();
	if ($posttags) {
	  foreach($posttags as $tag) {
	    //$tags .= '<a href="' . get_tag_link($tag->term_id) . '">';
	    $tags .= '<div class="chip"><div class="chip-label">' . $tag->name . '</div></div>';
	    //$tags .= '</a>'; 
	  }
	}

	if ($tags == "") {
		return;
	}

	return '<!-- Tags -->
	<div class="wpmobile-tags">' . $tags . '</div>';
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_ads] Shortcode

The WPAppNinja shortcode ‘wpapp_ads’ is designed to display ads at the top of your WordPress site. This shortcode calls the ‘wpappninja_get_ads’ function, which fetches and returns the top ad. It’s a quick, efficient way to monetize your site.

Shortcode: [wpapp_ads]

Examples and Usage

Basic example – Displays the top Ad using the WPAppNinja plugin.

[wpapp_ads]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_ads] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_ads', 'wpapp_ads' );

Shortcode PHP function:

function wpapp_ads() {
	return '<!-- Ads -->
	' . wpappninja_get_ads('top');
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_push] Shortcode

The WPAppNinja shortcode ‘wpapp_push’ is used to create a button that redirects users to the push settings page. This shortcode generates a button with ‘Push settings’ text. When clicked, users are directed to the push notification settings of the WPAppNinja plugin.

Shortcode: [wpapp_push]

Examples and Usage

Basic example – A straightforward application of the wpapp_push shortcode. This will display a button that redirects to the push settings page when clicked.

[wpapp_push /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_push] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_push', 'wpapp_push' );

Shortcode PHP function:

function wpapp_push() {

	$html = '<p><a style="padding: 15px 0;line-height: initial;margin: 15px 0;height: auto;" class="button" href="'.get_bloginfo('url') .'/?wpapp_shortcode=wpapp_config"><i class="icon f7-icons">gear</i> ' . __('Push settings', 'wpappninja') . '</a></p>';

	return $html;
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_config] Shortcode

The WPAppNinja shortcode is a tool that configures push notifications for a WordPress site. It uses cookies to identify users and their preferred notification settings. This shortcode retrieves user settings, updates them if necessary, and generates a form for managing notifications. It also provides a script for alerting the user when settings are saved. In essence, the WPAppNinja shortcode enhances user experience by allowing personalized push notifications.

Shortcode: [wpapp_config]

Examples and Usage

Basic example – Displaying the WPAppNinja configuration settings on a page or post.

[wpapp_config]

Advanced examples

Using the shortcode to display the WPAppNinja configuration settings, along with a custom query string. This could be useful if you want to link to a specific configuration page, or pass certain parameters for advanced functionality.

[wpapp_config query="custom_query_string"]

Another advanced usage could be to use the shortcode in conjunction with other shortcodes or content within a page or post. This could be useful for creating a custom mobile app settings page, where users can manage their app preferences.

[wpapp_config]

Manage your app settings below:

[another_shortcode]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_config] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_config', 'wpapp_config' );

Shortcode PHP function:

function wpapp_config() {

	global $wpdb;

	$cookieid = (isset($_COOKIE['HTTP_X_WPAPPNINJA_ID']) ? $_COOKIE['HTTP_X_WPAPPNINJA_ID'] : "");
	$user_bdd_id_check = $wpdb->get_row($wpdb->prepare("SELECT device_id FROM {$wpdb->prefix}wpappninja_ids as a JOIN {$wpdb->prefix}wpappninja_push_perso as b ON a.device_id = b.user_id WHERE b.id = %s", $cookieid));

	$category = array_filter( explode(',', get_wpappninja_option('push_category', '')));

	$user_id = (isset($_COOKIE['HTTP_X_WPAPPNINJA_ID']) ? $_COOKIE['HTTP_X_WPAPPNINJA_ID'] : "");

	$html = '<!-- Push config -->';

	if (isset($_POST['enablewpapppush'])) {
		$user_category = "";
		if (isset($_POST['wpapp_category']) && is_array($_POST['wpapp_category'])) {
			$user_category = implode(',', $_POST['wpapp_category']);
		}
		
		$wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}wpappninja_push_perso SET `category` = %s WHERE `id` = %s", $user_category, $user_id));

		$html .= '<script type="text/javascript">jQuery(function() {app.dialog.alert(\''.__('Settings saved', 'wpappninja').'\',\''.__('Push notification', 'wpappninja').'\');});</script>';
	}

	$user_settings = $wpdb->get_row($wpdb->prepare("SELECT `category` FROM {$wpdb->prefix}wpappninja_push_perso WHERE `id` = %s", $user_id));

	if (!isset($user_bdd_id_check->device_id)) {
		$checked = "";
		$displaynone = "none";
	} else {
		$checked = "checked";
		$displaynone = "block";
	}

	$html .= '<script>function wpmobileshowpush(state) {

		';

		if (!isset($_GET['wpappninja_simul4'])) {



		$html .= 'jQuery(\'.wpmobilehandlerpush\').remove();

		setTimeout(function(){
		jQuery(\'body\').append(\'<a href="'.get_bloginfo('url').'/?wpapppushconfig=1" class="wpmobilehandlerpush"></a>\');
        jQuery(\'.wpmobilehandlerpush\')[0].click();}, 200);';
		}

		$html .= '}</script>

        <a style="padding: 15px 0;line-height: initial;margin: 15px 0;height: auto;" class="button" href="/?wpapppushconfig=1"><i class="icon f7-icons">gear</i> ' . __('Manage notifications', 'wpappninja') . '</a>


		<form action="" method="post"><div class="list simple-list">
		';


	//$html .= '<p><a style="padding: 15px 0;line-height: initial;margin: 15px 0;height: auto;" class="button" href="?wpapppushconfig=1"><i class="icon f7-icons">gear</i> ' . __('Push settings', 'wpappninja') . '</a></p>';

	  $html .= "<div id='pushctabis'>";
	if (count($category) > 0) {

		$html .= '<ul>
		<input type="hidden" name="enablewpapppush" value="1" />';

		foreach ($category as $c) {

			$c = trim($c);

    		$html .= '<li>

    		      <span>' . $c . '</span>
      <label class="toggle toggle-init">
        <input type="checkbox" name="wpapp_category[]" value="' . $c . '" ';

	        	if (preg_match('#' . $c . '#', $user_settings->category)) {$html .= 'checked';}

	        	$html .= ' />
        <span class="toggle-icon"></span>
      </label>


	   		</li>';

		}
	
		$html .= '</ul><br/><br/><input type="submit" class="button" value="' . __('Save', 'wpappninja') . '" />';
	}
	$html .= "</div>";

	$html .= "</form></div></div>";
	
	return $html;
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_search] Shortcode

The wpappninja shortcode is utilized to create a search bar within the app. It’s a convenient tool that enhances user navigation. The generated search bar is responsive and user-friendly, with a ‘Cancel’ button for ease of use. It also includes a search bar overlay for visual appeal.

Shortcode: [wpapp_search]

Examples and Usage

Basic example – The WPAppNinja Search Bar can be added to any post or page using the shortcode [wpapp_search]. This will insert a search bar where users can input their search query and be directed to the results on your site.

[wpapp_search]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_search] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_search', 'wpapp_search' );

Shortcode PHP function:

function wpapp_search() {
	return '<!-- Search Bar -->
	<div class="ios wpapp_navbar_search">
	<form class="searchbar" method="get" action="' . get_bloginfo('url') . '/' . '">
	  <div class="searchbar-inner">
	    <div class="searchbar-input-wrap">
	      <input type="search" placeholder="' . __('Search', 'wpappninja') . '" name="s">
	      <i class="searchbar-icon"></i>
	      <span class="input-clear-button"></span>
	    </div>
	    <span class="searchbar-disable-button">' . __('Cancel', 'wpappninja') . '</span>
	  </div>
	</form>

	<!-- Search Bar overlay-->
	<div class="searchbar-overlay"></div>
	</div>';
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_image] Shortcode

The WPAppNinja shortcode ‘wpapp_image’ allows you to display the featured image of a post. The shortcode retrieves the post ID and checks if it exists. If it does, it fetches the respective image URL. The image is then returned in an HTML img tag, ready to be displayed on your WordPress site. This shortcode is beneficial for dynamically displaying images on posts or pages.

Shortcode: [wpapp_image]

Examples and Usage

Basic example – The shortcode is used to display the image associated with a particular post in WordPress. The post is identified by its unique ID.

[wpapp_image id=1 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_image] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_image', 'wpapp_image' );

Shortcode PHP function:

function wpapp_image() {

	$content_post = get_post();

	if (isset($content_post->ID)) {
		$image = wpappninja_get_image($content_post->ID, false, true, "0");

		if ($image != "") {
			return '<!-- Image -->
			<img src="' . $image . '" class="hero" />';
		}
	}
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_image_small] Shortcode

The WPAppNinja shortcode ‘wpapp_image_small’ displays a small-sized image from a post. It fetches an image from the post ID and sets it as a background with specific dimensions. The shortcode also displays the post title next to the image. It’s designed for a clean, compact layout with an image and title side-by-side.

Shortcode: [wpapp_image_small]

Examples and Usage

Basic example – Depicts the usage of wpappninja plugin shortcode to display the post image and title in a small card format.

[wpapp_image_small /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_image_small] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_image_small', 'wpapp_image_small' );

Shortcode PHP function:

function wpapp_image_small() {

	$content_post = get_post();
	$image = wpappninja_get_image($content_post->ID, false, true, "0");

	$html = "<div>";

	if ($image != "") {
		$html .= '<!-- Image -->
		<div class="wpappninja_small_card_image" style="background:url(' . $image . ') center center no-repeat;background-size:cover;width: 130px;height:90px;float:left;"></div>';
	}

	$html .= "<div class='wpappninja_small_card_title' style='width: Calc(100% - 160px);float:left;margin-left: 15px;'><h4 style='margin:0'>" . $content_post->post_title . "</h4></div>";

	$html .= '<div style="clear:both"></div></div>';

	return $html;
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_author] Shortcode

The WPAppNinja shortcode ‘wpapp_author’ displays the author’s avatar, name, and the relative post date. It fetches the author’s data from the post and generates an HTML block.

Shortcode: [wpapp_author]

Examples and Usage

Basic example – Displays the author information of a post using the ‘wpapp_author’ shortcode.

[wpapp_author /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_author] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_author', 'wpapp_author' );

Shortcode PHP function:

function wpapp_author() {

	$content_post = get_post();

	if (!isset($content_post->post_author)) {
		return;
	}

	$authorAvatar = wpappninja_get_gravatar(get_the_author_meta('user_email', $content_post->post_author));

	$html = '<!-- Author -->
	<div class="card-author">';
		if ($authorAvatar != "") {
			$html .= '<div class="wpappninja-avatar"><img src="' . $authorAvatar . '" width="34" height="34"></div>';
		}
		$html .= '<div class="wpappninja-name">' . get_the_author_meta('display_name', $content_post->post_author) . '</div>
		<div class="wpappninja-date">' . wpappninja_human_time(current_time('timestamp') - strtotime($content_post->post_date)) . '</div>
	</div>';

	return $html;
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_comment_number] Shortcode

The WPAppNinja shortcode ‘wpapp_comment_number’ is used to display the number of comments on a post. This shortcode retrieves the post data, then returns the comment count wrapped within a span element. This allows for easy styling and integration within your WordPress theme.

Shortcode: [wpapp_comment_number]

Examples and Usage

Basic example – The following shortcode is used to display the number of comments for a specific post.

[wpapp_comment_number]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_comment_number] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_comment_number', 'wpapp_comment_number' );

Shortcode PHP function:

function wpapp_comment_number() {

    $content_post = get_post();
   
    return '<!-- Number of comments -->
    <span class="badge">' . get_comments_number($content_post->ID) . '</span>';
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_title] Shortcode

The WPAppNinja shortcode ‘wpapp_title’ is used to display the title of the current post. This shortcode retrieves the post title from the WordPress database and displays it within an H2 HTML tag, styling it with the class ‘wpmobile-title’. If the post title is not set or is an empty string, no output is returned.

Shortcode: [wpapp_title]

Examples and Usage

Basic example – Displays the title of the current post or page using the ‘wpapp_title’ shortcode.

[wpapp_title /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_title] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_title', 'wpapp_title' );

Shortcode PHP function:

function wpapp_title() {

    /*if (isset($_GET['s'])) {
        return '<!-- Title -->
        <h2 class="wpmobile-title">' . sprintf(__( 'Search Results for &#8220;%s&#8221;', 'wpappninja'), get_search_query()) . '</h2>';
    }*/

    $content_post = get_post();

    if (!isset($content_post->post_title) || $content_post->post_title == "") {

        return;
    }
    
    return '<!-- Title -->
    <h2 class="wpmobile-title">' . $content_post->post_title . '</h2>';
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_comment] Shortcode

The WPAppNinja shortcode ‘wpapp_comment’ is used to display the comment template. When this shortcode is added to a post or page, it calls the ‘comments_template()’ function. This function fetches the theme’s comment template and displays it. The output is then returned and cleaned up by ‘ob_get_clean()’.

Shortcode: [wpapp_comment]

Examples and Usage

Basic example – A simple way to use the ‘wpapp_comment’ shortcode to display the comments template on your WordPress site.

[wpapp_comment /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_comment] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_comment', 'wpapp_comment' );

Shortcode PHP function:

function wpapp_comment() {

	ob_start();
    comments_template();
    return '<!-- Comments -->' . ob_get_clean();
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_excerpt] Shortcode

The WPAppNinja shortcode, ‘wpapp_excerpt’, is designed to fetch and display the excerpt of a post. This shortcode retrieves the post’s excerpt using WordPress’s built-in ‘get_the_excerpt’ function. It’s a handy tool for automatically displaying summaries or teasers of your full-length posts.

Shortcode: [wpapp_excerpt]

Examples and Usage

Basic example – The code below will display the excerpt of the current post. The ‘wpapp_excerpt’ shortcode doesn’t accept any parameters, hence it will always output the excerpt of the current post.

[wpapp_excerpt /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_excerpt] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_excerpt', 'wpapp_excerpt' );

Shortcode PHP function:

function wpapp_excerpt() {

	$content_post = get_post();
	
	return '<!-- Excerpt -->
	' . get_the_excerpt($content_post);
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_similar] Shortcode

The WPAppNinja shortcode ‘wpapp_similar’ is designed to display posts similar to the current one. It fetches posts from the same category, excluding the current post. The shortcode utilizes WordPress’ WP_Query class to retrieve posts. It also uses the wpappninja_show_card function to display each post, creating a seamless user experience.

Shortcode: [wpapp_similar]

Examples and Usage

Basic example – The basic usage of the ‘wpapp_similar’ shortcode would be to display similar posts based on the current post’s category. This will show up to 10 similar posts by default.

[wpapp_similar /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_similar] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_similar', 'wpapp_similar' );

Shortcode PHP function:

function wpapp_similar() {

	$content_post = get_post();

	$similar = "";

	$terms = wp_get_post_terms( $content_post->ID, get_wpappninja_option('similartype', 'category'), array('fields' => 'ids') );
	$args = array(

		'posts_per_page' => get_wpappninja_option('similarnb', 10),
        'tax_query' => array(
			array(
				'taxonomy' => get_wpappninja_option('similartype', 'category'),
				'terms' => $terms,
				'include_children' => false
			)
		),
		'post__not_in' => array( $content_post->ID ),
		'offset' => 0,
		'post_type' => get_post_types(array('public'=>true))
			);
	$args = wpappninja_get_list_arg($args);

	ob_start();
	$my_query = new WP_Query($args);
	if( $my_query->have_posts() ) {
		while ($my_query->have_posts()) : $my_query->the_post();
			$post = get_post();
			wpappninja_show_card($post);
		endwhile;
	}
	wp_reset_query();
	$similar = ob_get_clean();

	if ($similar == "") {
		return;
	}

	return '<!-- Similars -->' . $similar;
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_social] Shortcode

The WPAppNinja shortcode, ‘wpapp_social’, is designed to create a share button on your WordPress site. This button, when clicked, shares the URL of your blog. This shortcode generates an HTML anchor tag with a class of ‘button’ and an icon from the ‘f7-icons’ font family. The text for the button is ‘Share’, translated into the site’s current language. The href attribute for the button is set to the URL of the blog, appended with ‘/?wpmobileshareme’, which triggers the sharing functionality. In terms of styling, the button has a padding of 15px on the top and bottom, a line-height set to ‘initial’, a margin of 15px on the top and bottom, and a height set to ‘auto’.

Shortcode: [wpapp_social]

Examples and Usage

Basic example – The following shortcode allows you to add a share button on your WordPress website. The share button links to your website’s URL.

[wpapp_social /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_social] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_social', 'wpapp_social' );

Shortcode PHP function:

function wpapp_social() {

	return '<a style="padding: 15px 0;line-height: initial;margin: 15px 0;height: auto;" href="' . get_bloginfo('url') . '/?wpmobileshareme" class="button"><i class="icon f7-icons">share</i> ' . __('Share', 'wpappninja') . '</a>';
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_share] Shortcode

The WPAppNinja shortcode allows users to share content on various social media platforms. It fetches the post’s URL, title, and image, then generates a share link based on the specified network. The networks supported include Facebook, Google, Twitter, LinkedIn, Pinterest, Reddit, and Digg. Each network has a unique share link, and the shortcode returns an HTML anchor element with the share link.

Shortcode: [wpapp_share]

Parameters

Here is a list of all possible wpapp_share shortcode parameters and attributes:

  • network – Specifies the social network for sharing the post.

Examples and Usage

Basic example – Display the share button for Facebook on your post.

[wpapp_share network='facebook']

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_share] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_share', 'wpapp_share' );

Shortcode PHP function:

function wpapp_share($atts) {

	$content_post = get_post();

	$a = shortcode_atts( array(
		'network' => ''
	), $atts );

	$url      = get_permalink();
	$text     = urlencode( $content_post->post_title );
	$image    = wpappninja_get_image( $content_post->ID, false, true, "0" );
	$cssClass = '';
    $link     ='';

	switch ( $a['network'] ) {

		case 'facebook':
			$cssClass = 'facebook';
			$link     = 'https://www.facebook.com/sharer/sharer.php?u=' . $url;
			break;

		case 'google':
			$cssClass = 'google';
			$link     = 'https://plus.google.com/share?url=' . $url;
			break;

		case 'twitter':
			$cssClass = 'twitter';
			$link     = 'https://twitter.com/intent/tweet?text=' . $text . '+' . $url;
			break;

		case 'linkedin':
			$cssClass = 'linkedin';
			$link     = 'https://www.linkedin.com/shareArticle?mini=true&url=' . $url;
			break;

		case 'pinterest':
			$cssClass = 'pinterest';
			$link     = 'https://pinterest.com/pin/create/button/?description=' . $text . '&media=' . $image . '&url=' . $url;
			break;

		case 'reddit':
			$cssClass = 'reddit';
			$link     = 'https://reddit.com/submit?url=' . $url;
			break;

		case 'digg':
			$cssClass = 'digg';
			$link     = 'https://digg.com/submit?url=' . $url;
			break;

	}

    if ($cssClass != '') {
	    return '<a href="' . $link . '" rel="nofollow" target="_blank" class="socialninja socialninja_' . $cssClass . '"><i class="icon f7-icons">social_' . $cssClass . '_fill</i></a>';
    }

    return '';
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_history] Shortcode

The WPAppNinja shortcode is a powerful tool that allows you to display a user’s push notification history. It retrieves the user’s ID and settings, then fetches the relevant notifications from the database.

Shortcode: [wpapp_history]

Examples and Usage

Basic example – Displays the history of push notifications sent to a specific user.

[wpapp_history /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_history] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_history', 'wpapp_history' );

Shortcode PHP function:

function wpapp_history() {
	global $wpdb;

	$user_id = (isset($_COOKIE['HTTP_X_WPAPPNINJA_ID']) ? $_COOKIE['HTTP_X_WPAPPNINJA_ID'] : "");

	$user_settings = $wpdb->get_row($wpdb->prepare("SELECT `category` FROM {$wpdb->prefix}wpappninja_push_perso WHERE `id` = %s", $user_id));

	if (!isset($user_settings)) {
		$user_settings = new stdClass();
		$user_settings->category = "";
	}

	$user_category = explode(',', $user_settings->category);

	$user_category = apply_filters('wpmobile_push_id', $user_category);

	$like_prepare = " AND (category = %s";
	$like_term = array();
	$like_term[] = wpappninja_get_lang();
	$like_term[] = '1';
	$like_term[] = '';
	foreach ($user_category as $c) {
		$like_prepare .= " OR category LIKE %s";
		$like_term[] = $c;
	}
	$like_term[] = 0;
	$like_term[] = 100;
	$like_prepare .= ')';

	$last_read = $_COOKIE['wpmobile_last_seen'];

	$html = '<!-- Push history -->
	<style>.list ul.wpmobile_list_history:before, .list ul.wpmobile_list_history:after {
    content: none!important;
	}</style>
	<div class="list media-list">
	  <ul class="wpmobile_list_history">';

	$number_push = 0;
	
	$query = $wpdb->get_results($wpdb->prepare("SELECT `id`, `id_post`, `titre`, `message`, `image`, `send_date`, `sended`, `log`, `lang` FROM {$wpdb->prefix}wpappninja_push WHERE (lang = %s OR lang = 'all') AND `sended` = %s " . $like_prepare . " ORDER BY `send_date` DESC LIMIT %d,%d", $like_term));

	$avant = __('%s ago', 'wpappninja');
	foreach($query as $obj) {

			$number_push++;

			$permalink = false;
			if ($obj->id_post > 0) {
				$permalink = get_permalink($obj->id_post);
			}

			if (preg_match('#^http#', $obj->id_post)) {
				$permalink = $obj->id_post;
			}


			$html .= '<!-- Timeline item -->';
    		
    		if ($permalink) {
				$html .= '<a href="' . $permalink . '" style="color:initial">';
			}

			if ($obj->send_date > $last_read) {
	   			$html .= '<li style="border-left: 5px solid;border-bottom: 1px solid #eee;font-weight: 800;">';
	   		} else {
	   			$html .= '<li style="border-left: 5px solid #fff;border-bottom: 1px solid #eee;">';
	   		}

   			$html .= '<div class="item-content">';

		    if ($obj->image != "" && $obj->image != " ") {
		        $html .= '<div class="item-media">
		        	<img src="' . $obj->image . '" width="44" />
			    </div>';
			}
            $html .= '<div class="item-inner">
              <div class="item-title-row">
                <div class="item-title"><b>' . stripslashes($obj->titre) . '</b></div>
              </div>
              <div class="item-subtitle" style="white-space: initial;">
                ' . stripslashes($obj->message) . '
                <br/>
                <span style="color:gray;font-size:10px;">' . sprintf($avant, human_time_diff( $obj->send_date, current_time('timestamp') )) . '</span>
              </div>
            </div>
            
            </div>';

		    $html .= '</li>';
      		if ($permalink) {
				$html .= '</a>';
			}
	}

	$html .= '</ul></div>';

	if ($number_push == 0) {
		$html .= '<center><h1><i class="f7-icons" style="font-size: 60px;color: #b7b7b7;">chats</i></h1>
		'.__('No information for now.', 'wpappninja').'</center>';
	}

	return $html;
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpmobile_qrcode_2] Shortcode

The Wpappninja shortcode is a QR code scanner. It initiates the scanner and handles the scanned result. On scanning, if the result is a URL, it redirects to that location. If not, it alerts the user with the result. If no result is obtained, it alerts “No result”.

Shortcode: [wpmobile_qrcode_2]

Examples and Usage

Basic example – A simple usage of the shortcode to generate QR code scanner button.

[wpmobile_qrcode_2 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpmobile_qrcode_2] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpmobile_qrcode_2', 'wpmobile_qrcode_2');

Shortcode PHP function:

function wpmobile_qrcode_2() {
               
    $html = '<script>
    function wpmobile_qrcode() {
               try{wpmobileapp.qrscanner();} catch(err) {}
               try{window.webkit.messageHandlers.wpmobile.postMessage(\'qrscanner\');} catch(err) {}
    }
               
    function wpmobile_qrcode_result(result) {
                                                                                 
               '.apply_filters('wpmobile_qrcode_event', '').'

               if (result == "") {
                          app.dialog.alert("'.__('No result', 'wpappninja').'", "'.__('Scanner', 'wpappninja').'");
                          return;
               }
                                                                                                           
               if (result.startsWith("http")) {
                                                                      wpmobileappStartLoading();
                          document.location = result;
               } else {
                          app.dialog.alert(result, "'.__('Scanner', 'wpappninja').'");
               }
    }
    </script>';

    $html .= '<span onclick="wpmobile_qrcode();" class="button" class="wpmobile_qrcode"><i class="icon f7-icons">qrcode</i></span>';

    return $html;
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpmobile_qrcode] Shortcode

The wpappninja shortcode ‘wpmobile_qrcode’ is designed to initiate the QR scanner within the mobile app. This shortcode works by attempting to call the ‘qrscanner’ function from the ‘wpmobileapp’ object. If this fails, it tries to post a ‘qrscanner’ message to ‘wpmobile’.

Shortcode: [wpmobile_qrcode]

Examples and Usage

Basic example – The following shortcode allows you to implement the QR scanner functionality in your WordPress mobile application. It doesn’t require any parameters.

[wpmobile_qrcode /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpmobile_qrcode] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpmobile_qrcode', 'wpmobile_qrcode');

Shortcode PHP function:

function wpmobile_qrcode() {
               try{wpmobileapp.qrscanner();} catch(err) {}
               try{window.webkit.messageHandlers.wpmobile.postMessage(\'qrscanner\');} catch(err) {}
    }

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_qrcode] Shortcode

The WPAppNinja shortcode ‘wpapp_qrcode’ generates a clickable button that redirects users to a QR code scanner. It enhances user experience by providing quick access to the scanner.

Shortcode: [wpapp_qrcode]

Examples and Usage

Basic example – Showcases the usage of the ‘wpapp_qrcode’ shortcode without any additional parameters.

[wpapp_qrcode /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_qrcode] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_qrcode', 'wpapp_qrcode' );

Shortcode PHP function:

function wpapp_qrcode() {
	
	return '<p><a href="'.get_bloginfo('url').'/?wpappqrcode=1" style="padding: 15px 0;line-height: initial;margin: 15px 0;height: auto;" class="button"><i class="icon f7-icons">camera</i> ' . __('Scan code', 'wpappninja') . '</a></p>';
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpmobileapp_author] Shortcode

The Wpappninja shortcode ‘wpmobileapp_author’ is designed to retrieve and display the author’s name of a specific post. When implemented, it fetches the ‘display_name’ from the author’s metadata of the current post and wraps it within a span element. This allows for easy style customization.

Shortcode: [wpmobileapp_author]

Examples and Usage

Basic example – Use the shortcode to display the author of the post

[wpmobileapp_author /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpmobileapp_author] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpmobileapp_author', '_shortcode_wpmobileapp_author');

Shortcode PHP function:

function _shortcode_wpmobileapp_author() {
    
    $content_post = get_post();
    return "<span class='wpmobileapp_shortcode wpapp_author'>".get_the_author_meta('display_name', $content_post->post_author)."</span>";
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpmobileapp_date] Shortcode

The WPAppNinja shortcode ‘wpmobileapp_date’ is designed to display the date of a specific post in a human-readable format. It fetches the post’s timestamp and converts it into a more understandable format.

Shortcode: [wpmobileapp_date]

Examples and Usage

Basic example – Display the human-readable time difference between the current time and the post creation date.

[wpmobileapp_date]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpmobileapp_date] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpmobileapp_date', '_shortcode_wpmobileapp_date');

Shortcode PHP function:

function _shortcode_wpmobileapp_date() {

    $content_post = get_post(); 
    return "<span class='wpmobileapp_shortcode wpapp_date'>".wpappninja_human_time(current_time('timestamp') - strtotime($content_post->post_date))."</span>";
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpmobileapp_category] Shortcode

The Wpappninja shortcode ‘wpmobileapp_category’ is designed to fetch and display the first category of a post. This shortcode retrieves the post’s details using the get_post() function. It then uses get_the_category() function to obtain the categories of the post. The shortcode finally returns the name of the first category, wrapped in a span class for styling.

Shortcode: [wpmobileapp_category]

Examples and Usage

Basic example – The basic usage of the shortcode is to display the category of a specific post. The shortcode does not require any parameters and will automatically fetch the category of the current post.

[wpmobileapp_category /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpmobileapp_category] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpmobileapp_category', '_shortcode_wpmobileapp_category');

Shortcode PHP function:

function _shortcode_wpmobileapp_category() {

    $content_post = get_post();
    $categories = get_the_category($content_post->ID);
    return "<span class='wpmobileapp_shortcode wpapp_category'>".$categories[0]->name."</span>";
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_home_configure] Shortcode

The wpappninja plugin shortcode facilitates the customization of a user’s homepage. It allows users to select their preferred categories and save their settings.

Shortcode: [wpapp_home_configure]

Examples and Usage

Basic example – Displaying the home configuration of the WPAppNinja plugin.

[wpapp_home_configure /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_home_configure] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_home_configure', 'wpapp_home_configure' );

Shortcode PHP function:

function wpapp_home_configure() {

	$category = get_wpappninja_option('home_available', array());
	$pages = wpappninja_get_pages();

	global $wpdb;
	$user_id = (isset($_COOKIE['HTTP_X_WPAPPNINJA_ID']) ? $_COOKIE['HTTP_X_WPAPPNINJA_ID'] : "");

	$html = '<!-- Home settings -->';

	if (isset($_POST['wpapp_category_check'])) {
		$user_category = "";
		if (is_array($_POST['wpapp_category'])) {
			$user_category = implode(',', $_POST['wpapp_category']);
		}

		$wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->prefix}wpappninja_home_perso (category,id) VALUES (%s,%s) ON DUPLICATE KEY UPDATE category = %s", $user_category, $user_id, $user_category));

		$html .= '<script type="text/javascript">jQuery(function() {app.dialog.alert(\''.__('Settings saved', 'wpappninja').'\',\''.__('My home', 'wpappninja').'\');});</script>';

	}

	$user_settings = $wpdb->get_row($wpdb->prepare("SELECT `category` FROM {$wpdb->prefix}wpappninja_home_perso WHERE `id` = %s", $user_id));

	if (!isset($user_settings)) {
		$user_settings = new stdClass();
	}

	if (!isset($user_settings->category) || $user_settings->category == "") {
		$user_settings->category = implode(',',$category);
	}

	$html .= '<p><span style="padding: 15px 0;line-height: initial;margin: 15px 20px!important;width: Calc(100% - 40px)!important;height: auto;" data-popup=".popup-home" class="popup-open button"><i class="icon f7-icons">gear</i> ' . __('My home', 'wpappninja') . '</span></p>';

	global $wpappninja_popup;
	$wpappninja_popup .= '<div class="popup popup-home">
    <div class="block" style="background:white;padding:0">

	<form action="" method="post">
	<input type="hidden" name="wpapp_category_check" value="1" />

	<div class="list">
	<ul>';

	$user_category = explode(',', $user_settings->category);

	usort($category, "wpappninja_home_cmp");

	$_taxname = "";
	foreach ($category as $cc) {

		$t = explode('|',$cc);
		$c = get_term($t[1], $t[0]);

		$term = get_taxonomy($c->taxonomy);
		$taxname = $term->label;
		if ($taxname != $_taxname) {
			$_taxname = $taxname;
			$wpappninja_popup .= "</ul><h4 
    style='padding: 13px 0px 0 40px!important;
    font-size: 18px;
    margin-bottom: 11px;'>" . $taxname . "</h4><ul>";
		}

		if ($c->parent == 0) {

		$icon = wpappninja_auto_select_icon($c->name);
		foreach($pages as $p) {
			if ($p['id'] == get_term_link($c->term_id, $c->taxonomy)) {
				$icon = $p['icon'];
			}
		}

    	$wpappninja_popup .= '<li>
      		<label class="item-checkbox item-content"  style="';if (in_array($c->taxonomy . '|' . $c->term_id, $user_category)) {$wpappninja_popup.='color:white;';}$wpappninja_popup .= 'background:#fff;';if (in_array($c->taxonomy . '|' . $c->term_id, $user_category)) { $wpappninja_popup .= 'background:'.get_wpappninja_option('css_0c5c5bf1fda47e5230fff4396a1f8779', '#f5f5f5').';'; }$wpappninja_popup .= '">
	        <input type="checkbox" name="wpapp_category[]" value="' . $c->taxonomy . '|' . $c->term_id . '" ';

	        if (in_array($c->taxonomy . '|' . $c->term_id, $user_category)) {
				$wpappninja_popup .= 'checked';
			}

	        $wpappninja_popup .= ' />';

    	    $wpappninja_popup .= '
        	<div class="item-inner">
          		<div class="item-title"><i class="icon f7-icons">'.$icon.'</i>' . $c->name . '</div>
        	</div>
      		</label>
	   	</li>';

	   }

	}
	
	$wpappninja_popup .= '</ul></div>';

	$wpappninja_popup .= '<p style="padding:0 35px"><input type="submit" class="button" value="' . __('Save', 'wpappninja') . '" /></p>';

	$wpappninja_popup .= '</form><br/><br/></div></div>';

	$wpappninja_popup .= '<style>.item-checkbox i.icon.f7-icons {
    width: 28px;
    text-align: center;
    padding: 0 15px 0 0;
}.item-checkbox .item-media {
    display: none;
	}</style><script>jQuery("input[type=\'checkbox\']").change(function(){
    if(jQuery(this).is(":checked")){
        jQuery(this).parent().css("background", "'.get_wpappninja_option('css_0c5c5bf1fda47e5230fff4396a1f8779', '#f5f5f5').'");
        jQuery(this).parent().css("color", "white");
    }else{
        jQuery(this).parent().css("background", "#fff"); 
        jQuery(this).parent().css("color", "#212121");
    }
});</script>';

	return $html;
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_home] Shortcode

The WPAppNinja shortcode is used to create a customizable homepage for your app. It fetches user settings and displays posts based on the user’s chosen categories. .

Shortcode: [wpapp_home]

Examples and Usage

Basic example – Display the homepage of your WPAppNinja application using the shortcode.

[wpapp_home]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_home] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_home', 'wpapp_home' );

Shortcode PHP function:

function wpapp_home() {

	global $wpdb;
	$user_id = (isset($_COOKIE['HTTP_X_WPAPPNINJA_ID']) ? $_COOKIE['HTTP_X_WPAPPNINJA_ID'] : "");
	$category = get_wpappninja_option('home_available', array());

	$wpapp_home_configure = wpapp_home_configure();

	$user_settings = $wpdb->get_row($wpdb->prepare("SELECT `category` FROM {$wpdb->prefix}wpappninja_home_perso WHERE `id` = %s", $user_id));

	if (!isset($user_settings)) {
		$user_settings = new stdClass();
	}
	
	if ($user_settings->category == "") {
		$user_settings->category = implode(',',$category);
	}

	/** get and display posts **/
	$similar = "";

	$user_category = explode(',', $user_settings->category);
	
	$similar .= "<div class='wpappninja_home_break'>";


	if (get_wpappninja_option('home_type') != 'list') {
	$firstPosts = array();
	$emptyhome = true;
	foreach ($user_category as $cc) {

		

		$t = explode('|',$cc);
		$c = get_term($t[1], $t[0]);

		if ($c->parent == 0) {


	        	$similar .= "<div class='home_wpapp'>";
				$args = array(
					'post__not_in' => $firstPosts,
					'posts_per_page' => 3,
					'offset' => 0,
					'post_type' => get_post_types(array('public'=>true)),
					'tax_query' => array(array(
							'taxonomy' => $c->taxonomy,
							'terms' => $c->term_id,
							'include_children' => true
						))
				);
				$args = wpappninja_get_list_arg($args);
				$titlesetted = false;
				ob_start();
				$my_query = new WP_Query($args);
				if( $my_query->have_posts() ) {
					while ($my_query->have_posts()) : $my_query->the_post();

						$emptyhome = false;
 
						if (!$titlesetted) {
							$titlesetted = true;
							if (isset($c->name) && isset($c->taxonomy) && $c->name != ""){
								echo '<div onclick="document.location=\''.get_term_link($c->slug, $c->taxonomy).'\';" class="title-speed">' . $c->name . '</div>';
							}
						}
						$firstPosts[] = get_the_ID();
						$post = get_post();
						wpappninja_show_card($post);
					endwhile;
				} 

				wp_reset_query();
				$similar .= ob_get_clean();
				$similar .= "</div>";
			
	   }
	}
	} else {

			$offset = 0;
	if (isset($_GET['offset'])) {
		$offset = $_GET['offset'];
	}



	$home_posts = array();
	$home_posts['relation'] = 'OR';

	foreach ($user_category as $cc) {

		$t = explode('|',$cc);
		$c = get_term($t[1], $t[0]);

		if ($c->parent == 0) {

				$home_posts[] = array(
							'taxonomy' => $c->taxonomy,
							'terms' => $c->term_id,
							'include_children' => true
						);
	   }
	}



	        	$similar .= "<div class='home_wpapp'>";
				$args = array(
					'posts_per_page' => 10,
					'offset' => $offset,
					'post_type' => get_post_types(array('public'=>true)),
					'tax_query' => $home_posts
				);
				$args = wpappninja_get_list_arg($args);

				$titlesetted = true;
				ob_start();
				$my_query = new WP_Query($args);
				if( $my_query->have_posts() ) {
					while ($my_query->have_posts()) : $my_query->the_post();

						$emptyhome = false;
 
						if (!$titlesetted) {
							$titlesetted = true;
							if (get_wpappninja_option('titlespeed') == '1' && $c->name != ""){
								echo '<div onclick="document.location=\''.get_term_link($c->slug, $c->taxonomy).'\';" class="title-speed">' . $c->name . '</div>';
							}
						}
						$firstPosts[] = get_the_ID();
						$post = get_post();
						wpappninja_show_card($post);
					endwhile;

						?><div class="pagination">
	<?php
	$url = "http" . (($_SERVER['SERVER_PORT'] == 443) ? "s://" : "://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
	$url = preg_replace('#&offset=[0-9]+#', '', $url);
	?>
	<a class="next page-numbers" href="<?php echo $url;?>&offset=<?php echo ($offset+intval(get_wpappninja_option('listnb', 10)));?>">Suivant »</a>	</div>

	</div><?php
				} 

				wp_reset_query();
				$similar .= ob_get_clean();
				$similar .= "</div>";
	}


	$similar .= "</div>";
	if ($emptyhome) {
		$similar .= '<div style="text-align:center;margin:50px auto"><h1><i class="f7-icons" style="font-size: 60px;color: #b7b7b7;">person</i></h1>
			<b>'.__('Hello!', 'wpappninja').'</b><br/>
			'.__('Configure your app homepage', 'wpappninja').'<br/></div>';
	}
	$similar .= "<style>.title-speed{background: ".get_wpappninja_option('css_0c5c5bf1fda47e5230fff4396a1f8779', '#333333').";
    color: white;
    text-transform: uppercase;
    border-radius: 6px;
    display: table;
    margin: 25px auto 0 auto;
    font-size: 11px;
    padding: 4px 20px;
    text-align: center;
    max-width: 40%;
    border: 1px solid white;
}
/*
.home_wpapp .card:nth-of-type(2) .wpappninja_small_card_image {
    width: 100%!important;
    height: 140px!important;
}
.home_wpapp .card:nth-of-type(2) .wpappninja_small_card_title {
    font-size: 18px;
    width: Calc(100% - 30px)!important;
    margin: 0!important;
    padding: 20px;
}
.home_wpapp .card:nth-of-type(2) p {
    line-height: 0;
    margin: 0!important;
    padding: 0!important;
}
.home_wpapp .card:nth-of-type(2) .card-content-inner {
    padding: 0!important;
}*/
.card-content h4 {
    font-size: 17px;
    padding: 8px 0 0;
}
.card-content-inner {
    padding: 1px 15px;
}.card-content h4 {
    font-size: 17px;
    padding: 8px 0 0;
}
</style>";

	if ($emptyhome) {
		$return = $similar.$wpapp_home_configure;
	} else {
		$return = $wpapp_home_configure . $similar;
	}

	return $return;
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_recent] Shortcode

The WPAppNinja shortcode is a powerful tool that displays the most recent posts on your WordPress site. It fetches posts based on the set parameters and displays them in a neat card format. This shortcode also includes a pagination feature, allowing users to navigate through different posts. It uses the ‘offset’ parameter to determine the starting point of the posts to be displayed.

Shortcode: [wpapp_recent]

Examples and Usage

Basic example – The shortcode [wpapp_recent] displays the most recent posts on your website. The number of posts displayed is determined by the ‘listnb’ option in your WPAppNinja settings, with 10 being the default value.

[wpapp_recent /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_recent] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'wpapp_recent', 'wpapp_recent' );

Shortcode PHP function:

function wpapp_recent() {

	$offset = 0;
	if (isset($_GET['offset'])) {
		$offset = $_GET['offset'];
	}

	/** get and display posts **/
	$similar = "";

	$args = array(
		'posts_per_page' => intval(get_wpappninja_option('listnb', 10)),
		'offset' => $offset,
		'post_type' => 'post'
			);
	$args = wpappninja_get_list_arg($args);

	ob_start();
	$my_query = new WP_Query($args);
	if( $my_query->have_posts() ) {
		while ($my_query->have_posts()) {
			$my_query->the_post();
			$post = get_post();
			wpappninja_show_card($post);
		}


	?><div class="pagination">
	<?php
	$url = "http" . (($_SERVER['SERVER_PORT'] == 443) ? "s://" : "://") . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
	$url = preg_replace('#&offset=[0-9]+#', '', $url);
	?>
	<a class="next page-numbers" href="<?php echo $url;?>&offset=<?php echo ($offset+intval(get_wpappninja_option('listnb', 10)));?>">Suivant »</a>	</div>

	<?php
	}
	wp_reset_query();

	$similar = ob_get_clean();

	return $similar;
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpapp_welcome] Shortcode

The WPAppNinja shortcode ‘wpapp_welcome’ is a customizable function that allows developers to enhance their WordPress app. It’s a simple, yet powerful tool that can modify the app’s welcome screen.

Shortcode: [wpapp_welcome]

Examples and Usage

Basic example – A simple usage of the wpapp_welcome shortcode without any attributes.

[wpapp_welcome /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpapp_welcome] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpapp_welcome', 'wpapp_welcome');

Shortcode PHP function:

function wpapp_welcome() {
    
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

WPMobile.App [wpmobile_notification_badge] Shortcode

The Wpappninja shortcode is a powerful tool for customizing the appearance of mobile notifications. This shortcode allows users to modify the color, opacity, and position of the notification badge. It also provides a link, styled with the chosen color, that redirects to the website’s history page when clicked.

Shortcode: [wpmobile_notification_badge]

Examples and Usage

Basic example – The basic usage of the WPAppNinja shortcode for displaying the notification badge on your mobile app.

[wpmobile_notification_badge /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpmobile_notification_badge] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpmobile_notification_badge', 'wpmobile_notification_badge');

Shortcode PHP function:

function wpmobile_notification_badge() {

	$html = '<style>.navbar .right span.badge {
    background: '.get_wpappninja_option('css_00bcbfacaf98f1b05815ab4eaeee1e13').';
    color: '.get_wpappninja_option('css_74537a66b8370a71e9b05c3c4ddbf522', '#fff').'!important;
    opacity: 0.8;position: absolute;left: 80%;font-size: 12px;top: -10px!important;
	}</style>';

	$html .= '<a style="position:relative;color:'.get_wpappninja_option('css_00bcbfacaf98f1b05815ab4eaeee1e13').'" href="'.get_bloginfo('url').'/?wpapp_shortcode=wpapp_history"><i class="f7-icons notranslate" translate="no">chat</i>'.wpappninja_woo_icon('wpapp_shortcode=wpapp_history').'</a>&nbsp;&nbsp;&nbsp;';

	return $html;
}

Code file location:

wpappninja/wpappninja/inc/functions/shortcodes.php

Conclusion

Now that you’ve learned how to embed the WPMobile.App — Android and iOS Mobile Application Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *