コード例 #1
0
    public static function get_config_js($app_id, $echo = false)
    {
        $wp_ws_url = WpakWebServices::get_app_web_service_base_url($app_id);
        $theme = WpakThemesStorage::get_current_theme($app_id);
        $app_slug = WpakApps::get_app_slug($app_id);
        $app_main_infos = WpakApps::get_app_main_infos($app_id);
        $app_title = $app_main_infos['title'];
        $app_version = WpakApps::sanitize_app_version($app_main_infos['version']);
        $debug_mode = WpakBuild::get_app_debug_mode($app_id);
        $auth_key = WpakApps::get_app_is_secured($app_id) ? WpakToken::get_hash_key() : '';
        //TODO : options to choose if the auth key is displayed in config.js.
        $options = WpakOptions::get_app_options($app_id);
        $addons = WpakAddons::get_app_addons_for_config($app_id);
        if (!$echo) {
            ob_start();
        }
        //Indentation is a bit funky here so it appears ok in the config.js file source:
        ?>
define( function ( require ) {

	"use strict";

	return {
		app_slug : '<?php 
        echo $app_slug;
        ?>
',
		wp_ws_url : '<?php 
        echo $wp_ws_url;
        ?>
',
		theme : '<?php 
        echo addslashes($theme);
        ?>
',
		version : '<?php 
        echo $app_version;
        ?>
',
		app_title : '<?php 
        echo addslashes($app_title);
        ?>
',
		debug_mode : '<?php 
        echo $debug_mode;
        ?>
'<?php 
        if (!empty($auth_key)) {
            ?>
,
		auth_key : '<?php 
            echo $auth_key;
            ?>
'<?php 
        }
        ?>
,
		options : <?php 
        echo json_encode($options);
        ?>
,
		addons : <?php 
        echo json_encode($addons);
        ?>

	};

});
<?php 
        $content = '';
        if (!$echo) {
            $content = ob_get_contents();
            ob_end_clean();
        }
        return !$echo ? $content : '';
    }
コード例 #2
0
ファイル: build.php プロジェクト: hiddenpearls/wp-appkit
 public static function build_app_sources($app_id, $export_type = 'phonegap-build')
 {
     $answer = array();
     if (!extension_loaded('zip')) {
         $answer['ok'] = 0;
         $answer['msg'] = __('Zip PHP extension is required to run file export. See http://www.php.net/manual/fr/book.zip.php.', WpAppKit::i18n_domain);
         return $answer;
     }
     if (!self::create_export_directory_if_doesnt_exist()) {
         $export_directory = self::get_export_files_path();
         $answer['ok'] = 0;
         $answer['msg'] = sprintf(__('The export directory [%s] could not be created. Please check that you have the right permissions to create this directory.', WpAppKit::i18n_domain), $export_directory);
         return $answer;
     }
     $current_theme = WpakThemesStorage::get_current_theme($app_id);
     $plugin_dir = plugin_dir_path(dirname(dirname(__FILE__)));
     $appli_dir = $plugin_dir . 'app';
     $export_filename = self::get_export_file_base_name($app_id);
     $export_filename_full = self::get_export_files_path() . "/" . $export_filename . '.zip';
     $answer = self::build_zip($app_id, $appli_dir, $export_filename_full, array($current_theme), WpakAddons::get_app_addons($app_id), $export_type);
     $answer['export'] = $export_filename;
     $answer['export_full_name'] = $export_filename_full;
     return $answer;
 }
コード例 #3
0
ファイル: themes.php プロジェクト: hiddenpearls/wp-appkit
 public static function include_app_theme_php($app_id)
 {
     $app_theme = WpakThemesStorage::get_current_theme($app_id);
     if (!empty($app_theme)) {
         $themes_dir = self::get_themes_directory() . '/' . $app_theme . '/php';
         if (file_exists($themes_dir) && is_dir($themes_dir)) {
             foreach (glob($themes_dir . "/*.php") as $file) {
                 include_once $file;
             }
         }
     }
 }
コード例 #4
0
    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);
    }