public static function get_config_xml($app_id, $echo = false, $export_type = 'phonegap-build') { $app_main_infos = WpakApps::get_app_main_infos($app_id); $app_name = $app_main_infos['name']; $app_description = $app_main_infos['desc']; $app_phonegap_id = $app_main_infos['app_phonegap_id']; $app_version = $app_main_infos['version']; $app_version_code = $app_main_infos['version_code']; $app_phonegap_version = $app_main_infos['phonegap_version']; $app_author = $app_main_infos['author']; $app_author_email = $app_main_infos['author_email']; $app_author_website = $app_main_infos['author_website']; $app_platform = $app_main_infos['platform']; $app_icons = $app_main_infos['icons']; $whitelist_settings = self::get_whitelist_settings($app_id, $export_type); //Merge our default Phonegap Build plugins to those set in BO : $app_phonegap_plugins = WpakApps::get_merged_phonegap_plugins_xml($app_id, $app_main_infos['phonegap_plugins']); $xmlns = 'http://www.w3.org/ns/widgets'; $xmlns_gap = 'http://phonegap.com/ns/1.0'; if (!$echo) { ob_start(); } echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?> <widget xmlns = "<?php echo $xmlns; ?> " xmlns:gap = "<?php echo $xmlns_gap; ?> " id = "<?php echo $app_phonegap_id; ?> " versionCode = "<?php echo $app_version_code; ?> " version = "<?php echo $app_version; ?> " > <name><?php echo $app_name; ?> </name> <description><?php echo $app_description; ?> </description> <author href="<?php echo $app_author_website; ?> " email="<?php echo $app_author_email; ?> "><?php echo $app_author; ?> </author> <gap:platform name="<?php echo $app_platform; ?> " /> <?php if (!empty($app_phonegap_version)) { ?> <preference name="phonegap-version" value="<?php echo $app_phonegap_version; ?> " /> <?php } /** * Filter to handle the "Webview bounce effect" on devices. * Pass false to this filter to allow the "Webview bounce effect". * * @param boolean true Bounce effect is disallowed by default. * @param int $app_id Application id */ if (apply_filters('wpak_config_xml_preference_disallow_overscroll', true, $app_id)) { ?> <preference name="<?php echo $app_platform == 'android' ? 'd' : 'D'; ?> isallowOverscroll" value="true" /> <preference name="webviewbounce" value="false" /> <?php } ?> <!-- PhoneGap plugin declaration --> <?php if (!empty($app_phonegap_plugins)) { ?> <?php echo str_replace("\n", "\n\t", $app_phonegap_plugins); ?> <?php } if (!empty($whitelist_settings)) { ?> <!-- Whitelist policy --> <?php foreach ($whitelist_settings as $whitelist_setting => $attributes) { if (empty($attributes) || !is_array($attributes)) { continue; } $attributes_str = ''; foreach ($attributes as $attribute => $value) { $attributes_str .= ' ' . $attribute . '="' . $value . '"'; } ?> <<?php echo $whitelist_setting; echo $attributes_str; ?> /> <?php } } ?> <!-- Icon and Splash screen declaration --> <?php if (!empty($app_icons)) { ?> <?php echo str_replace("\n", "\n\t", $app_icons); ?> <?php } ?> </widget> <?php $content = ''; if (!$echo) { $content = ob_get_contents(); ob_end_clean(); } return !$echo ? $content : ''; }
public static function inner_main_infos_box($post, $current_box) { $available_themes = WpakThemes::get_available_themes(true); $current_theme = WpakThemesStorage::get_current_theme($post->ID); $main_infos = WpakApps::get_app_main_infos($post->ID); ?> <?php if (!empty($available_themes)) { ?> <label><?php _e('Choose theme', WpAppKit::i18n_domain); ?> : </label> <select name="wpak_app_theme_choice" id="wpak_app_theme_choice"> <?php foreach ($available_themes as $theme_slug => $theme_data) { ?> <?php $selected = $theme_slug == $current_theme ? 'selected="selected"' : ''; ?> <option value="<?php echo $theme_slug; ?> " <?php echo $selected; ?> ><?php echo $theme_data['Name']; ?> </option> <?php } ?> </select> <?php } else { ?> <div class="wpak_no_theme"> <strong><?php _e('No WP AppKit theme found!', WpAppKit::i18n_domain); ?> </strong> <br/> <?php echo sprintf(__('Please upload a WP AppKit theme from the "<a href="%s" >Upload Themes</a>" panel or copy a theme directly to the %s directory.', WpAppKit::i18n_domain), '/wp-admin/admin.php?page=wpak_bo_upload_themes', basename(WP_CONTENT_DIR) . '/' . WpakThemes::themes_directory); ?> </div> <?php } ?> <?php foreach ($available_themes as $theme => $theme_data) { ?> <div class="wpak-theme-data" id="wpak-theme-data-<?php echo $theme; ?> " style="display:none"> <div class="theme-data-content"> <?php echo $theme_data['Description']; ?> <?php $theme_meta = array(); if (!empty($theme_data['Version'])) { $theme_meta[] = sprintf(__('Version %s'), $theme_data['Version']); } if (!empty($theme_data['Author'])) { $author = $theme_data['Author']; if (!empty($theme_data['AuthorURI'])) { $author = '<a href="' . $theme_data['AuthorURI'] . '">' . $theme_data['Author'] . '</a>'; } $theme_meta[] = sprintf(__('By %s'), $author); } if (!empty($theme_data['ThemeURI'])) { $theme_meta[] = sprintf('<a href="%s">%s</a>', esc_url($theme_data['ThemeURI']), __('Visit theme site')); } ?> <?php if (!empty($theme_meta)) { ?> <div class="theme-meta-data"><?php echo implode(' | ', $theme_meta); ?> </div> <?php } ?> </div> </div> <?php } ?> <div class="wpak-app-title wpak_settings"> <label><?php _e('Application Title (displayed in app top bar)', WpAppKit::i18n_domain); ?> </label> : <br/> <input id="wpak_app_title" type="text" name="wpak_app_title" value="<?php echo $main_infos['title']; ?> " /> </div> <?php wp_nonce_field('wpak-theme-data-' . $post->ID, 'wpak-nonce-theme-data'); ?> <style> .wpak-theme-data{ padding:9px 12px; margin-bottom: 10px } .theme-data-content{ margin-top: 0 } .wpak-app-title{ margin-top: 15px; border-top: 1px solid #ddd; padding-top:10px } .theme-meta-data{ margin-top: 7px } .wpak_no_theme{ text-align: center; font-size:120%; line-height: 2em; margin:30px } </style> <script> (function(){ var $ = jQuery; $('#wpak_app_theme_choice').change(function(){ $('.wpak-theme-data').hide(); var theme = this.value; $('#wpak-theme-data-'+ theme).show(); }); $('#wpak_app_theme_choice').change(); })(); </script> <?php do_action('wpak_inner_main_infos_box', $post, $current_box); }
protected static function get_default_phonegap_plugins($app_id) { $default_plugins = array('cordova-plugin-inappbrowser' => array('version' => '', 'source' => 'npm'), 'cordova-plugin-network-information' => array('version' => '', 'source' => 'npm'), 'cordova-plugin-whitelist' => array('version' => '', 'source' => 'npm')); $app_main_infos = WpakApps::get_app_main_infos($app_id); if ($app_main_infos['platform'] == 'ios') { $default_plugins['cordova-plugin-statusbar'] = array('version' => '', 'source' => 'npm'); unset($default_plugins['cordova-plugin-whitelist']); } /** * Filter the Phonegap Build plugins that are included by default by WP AppKit * * @param array $default_plugins Array of default Phonegap plugins. * @param int $app_id Application id */ $default_plugins = apply_filters('wpak_default_phonegap_build_plugins', $default_plugins, $app_id); return $default_plugins; }
public static function get_config_xml($app_id, $echo = false, $export_type = '') { $app_main_infos = WpakApps::get_app_main_infos($app_id); $app_name = $app_main_infos['name']; $app_description = $app_main_infos['desc']; $app_phonegap_id = $app_main_infos['app_phonegap_id']; $app_version = $app_main_infos['version']; $app_version_code = $app_main_infos['version_code']; $app_phonegap_version = $app_main_infos['phonegap_version']; $app_author = $app_main_infos['author']; $app_author_email = $app_main_infos['author_email']; $app_author_website = $app_main_infos['author_website']; $app_platform = $app_main_infos['platform']; $app_icons = $app_main_infos['icons']; $access = array(); if ($export_type == 'phonegap-cli') { $access[] = array('origin' => '*', 'subdomains' => ''); } /** * Filter : allows to modify config.xml <access> element * * @param array array array of <access> elements * Each <access> element is an array with the following attributes : * - 'origin' string The domain of where the resource lives * - 'subdomains' bool Whether to allow subdomains on the * host specified in the origin parameter. Pass an empty * string to ignore this optional attribute. * @param int $app_id Application id */ $access = apply_filters('wpak_config_xml_access', $access, $app_id); //Merge our default Phonegap Build plugins to those set in BO : $app_phonegap_plugins = WpakApps::get_merged_phonegap_plugins_xml($app_id, $app_main_infos['phonegap_plugins']); $xmlns = 'http://www.w3.org/ns/widgets'; $xmlns_gap = 'http://phonegap.com/ns/1.0'; if (!$echo) { ob_start(); } echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?> <widget xmlns = "<?php echo $xmlns; ?> " xmlns:gap = "<?php echo $xmlns_gap; ?> " id = "<?php echo $app_phonegap_id; ?> " versionCode = "<?php echo $app_version_code; ?> " version = "<?php echo $app_version; ?> " > <name><?php echo $app_name; ?> </name> <description><?php echo $app_description; ?> </description> <author href="<?php echo $app_author_website; ?> " email="<?php echo $app_author_email; ?> "><?php echo $app_author; ?> </author> <gap:platform name="<?php echo $app_platform; ?> " /> <?php if (!empty($app_phonegap_version)) { ?> <preference name="phonegap-version" value="<?php echo $app_phonegap_version; ?> " /> <?php } if (!empty($access)) { ?> <?php foreach ($access as $access_element) { if (empty($access_element['origin'])) { continue; } $subdomains = ''; if (isset($access_element['subdomains']) && is_bool($access_element['subdomains'])) { $subdomains = ' subdomains="' . ($access_element['subdomains'] ? 'true' : 'false') . '"'; } ?> <access origin="<?php echo $access_element['origin']; ?> "<?php echo $subdomains; ?> /> <?php } } /** * Filter to handle the "Webview bounce effect" on devices. * Pass false to this filter to allow the "Webview bounce effect". * * @param boolean true Bounce effect is disallowed by default. * @param int $app_id Application id */ if (apply_filters('wpak_config_xml_preference_disallow_overscroll', true, $app_id)) { ?> <preference name="<?php echo $app_platform == 'android' ? 'd' : 'D'; ?> isallowOverscroll" value="true" /> <preference name="webviewbounce" value="false" /> <?php } ?> <!-- Add Icon, Splash screen and any PhoneGap plugin declaration here --> <?php if (!empty($app_icons)) { ?> <?php echo str_replace("\n", "\n\t", $app_icons); ?> <?php } if (!empty($app_phonegap_plugins)) { ?> <?php echo str_replace("\n", "\n\t", $app_phonegap_plugins); ?> <?php } ?> </widget> <?php $content = ''; if (!$echo) { $content = ob_get_contents(); ob_end_clean(); } return !$echo ? $content : ''; }