/**
     * Displays options meta box on backoffice form.
     *
     * @param WP_Post				$post			The app object.
     * @param array					$current_box	The box settings.
     */
    public static function inner_synchronization_options_box($post, $current_box)
    {
        $options = WpakOptions::get_app_options($post->ID);
        ?>
		<div class="wpak_settings field-group">
			<label for="wpak_app_options_refresh_interval"><?php 
        _e('Refresh Interval (in seconds):', WpAppKit::i18n_domain);
        ?>
</label>
			<input id="wpak_app_options_refresh_interval" type="text" name="wpak_app_options[refresh_interval]" value="<?php 
        echo $options['refresh_interval'];
        ?>
" />
			<span class="description"><?php 
        _e('Use 0 to avoid intervals between refreshes. The content will be fetched from the server at each app launch (default value)', WpAppKit::i18n_domain);
        ?>
</span>
			<?php 
        wp_nonce_field('wpak-options-' . $post->ID, 'wpak-nonce-options');
        ?>
		</div>
		<?php 
    }
Пример #2
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 : '';
    }