当前位置: 首页>>代码示例>>PHP>>正文


PHP Utils\mustache_render函数代码示例

本文整理汇总了PHP中WP_CLI\Utils\mustache_render函数的典型用法代码示例。如果您正苦于以下问题:PHP mustache_render函数的具体用法?PHP mustache_render怎么用?PHP mustache_render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mustache_render函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

 function get_longdesc()
 {
     $binding = array();
     foreach (\WP_CLI::get_configurator()->get_spec() as $key => $details) {
         if (false === $details['runtime']) {
             continue;
         }
         if (isset($details['deprecated'])) {
             continue;
         }
         if (true === $details['runtime']) {
             $synopsis = "--[no-]{$key}";
         } else {
             $synopsis = "--{$key}" . $details['runtime'];
         }
         $binding['parameters'][] = array('synopsis' => $synopsis, 'desc' => $details['desc']);
     }
     return Utils\mustache_render('man-params.mustache', $binding);
 }
开发者ID:nb,项目名称:wp-cli,代码行数:19,代码来源:RootCommand.php

示例2: config

 /**
  * Generate a wp-config.php file.
  *
  * ## OPTIONS
  *
  * --dbname=<dbname>
  * : Set the database name.
  *
  * --dbuser=<dbuser>
  * : Set the database user.
  *
  * [--dbpass=<dbpass>]
  * : Set the database user password.
  *
  * [--dbhost=<dbhost>]
  * : Set the database host. Default: 'localhost'
  *
  * [--dbprefix=<dbprefix>]
  * : Set the database table prefix. Default: 'wp_'
  *
  * [--dbcharset=<dbcharset>]
  * : Set the database charset. Default: 'utf8'
  *
  * [--dbcollate=<dbcollate>]
  * : Set the database collation. Default: ''
  *
  * [--locale=<locale>]
  * : Set the WPLANG constant. Defaults to $wp_local_package variable.
  *
  * [--extra-php]
  * : If set, the command copies additional PHP code into wp-config.php from STDIN.
  *
  * [--skip-salts]
  * : If set, keys and salts won't be generated, but should instead be passed via `--extra-php`.
  *
  * [--skip-check]
  * : If set, the database connection is not checked.
  *
  * ## EXAMPLES
  *
  *     # Standard wp-config.php file
  *     wp core config --dbname=testing --dbuser=wp --dbpass=securepswd --locale=ro_RO
  *
  *     # Enable WP_DEBUG and WP_DEBUG_LOG
  *     wp core config --dbname=testing --dbuser=wp --dbpass=securepswd --extra-php <<PHP
  *     define( 'WP_DEBUG', true );
  *     define( 'WP_DEBUG_LOG', true );
  *     PHP
  */
 public function config($_, $assoc_args)
 {
     if (Utils\locate_wp_config()) {
         WP_CLI::error("The 'wp-config.php' file already exists.");
     }
     $defaults = array('dbhost' => 'localhost', 'dbpass' => '', 'dbprefix' => 'wp_', 'dbcharset' => 'utf8', 'dbcollate' => '', 'locale' => self::get_initial_locale());
     $assoc_args = array_merge($defaults, $assoc_args);
     if (preg_match('|[^a-z0-9_]|i', $assoc_args['dbprefix'])) {
         WP_CLI::error('--dbprefix can only contain numbers, letters, and underscores.');
     }
     // Check DB connection
     if (!isset($assoc_args['skip-check'])) {
         Utils\run_mysql_command('mysql --no-defaults', array('execute' => ';', 'host' => $assoc_args['dbhost'], 'user' => $assoc_args['dbuser'], 'pass' => $assoc_args['dbpass']));
     }
     if (isset($assoc_args['extra-php']) && $assoc_args['extra-php'] === true) {
         $assoc_args['extra-php'] = file_get_contents('php://stdin');
     }
     // TODO: adapt more resilient code from wp-admin/setup-config.php
     if (!isset($assoc_args['skip-salts'])) {
         $assoc_args['keys-and-salts'] = self::_read('https://api.wordpress.org/secret-key/1.1/salt/');
     }
     $out = Utils\mustache_render('wp-config.mustache', $assoc_args);
     $bytes_written = file_put_contents(ABSPATH . 'wp-config.php', $out);
     if (!$bytes_written) {
         WP_CLI::error('Could not create new wp-config.php file.');
     } else {
         WP_CLI::success('Generated wp-config.php file.');
     }
 }
开发者ID:wturrell,项目名称:wp-cli,代码行数:78,代码来源:core.php

示例3: get_initial_markdown

 private static function get_initial_markdown($command)
 {
     $name = implode(' ', Dispatcher\get_path($command));
     $binding = array('name' => $name, 'shortdesc' => $command->get_shortdesc());
     $binding['synopsis'] = wordwrap("{$name} " . $command->get_synopsis(), 79);
     $alias = $command->get_alias();
     if ($alias) {
         $binding['alias'] = $alias;
     }
     if ($command->can_have_subcommands()) {
         $binding['has-subcommands']['subcommands'] = self::render_subcommands($command);
     }
     return Utils\mustache_render('man.mustache', $binding);
 }
开发者ID:wp-cli,项目名称:wp-cli,代码行数:14,代码来源:help.php

示例4: basename

 /**
  * Generate files needed for running PHPUnit tests.
  *
  * ## DESCRIPTION
  *
  * These are the files that are generated:
  *
  * * `phpunit.xml` is the configuration file for PHPUnit
  * * `.travis.yml` is the configuration file for Travis CI
  * * `tests/bootstrap.php` is the file that makes the current plugin active when running the test suite
  * * `tests/test-sample.php` is a sample file containing the actual tests
  *
  * ## ENVIRONMENT
  *
  * The `tests/bootstrap.php` file looks for the WP_TESTS_DIR environment
  * variable.
  *
  * ## OPTIONS
  *
  * [<plugin>]
  * : The name of the plugin to generate test files for.
  *
  * [--dir=<dirname>]
  * : Generate test files for a non-standard plugin path. If no plugin slug is specified, the directory name is used.
  *
  * ## EXAMPLE
  *
  *     wp scaffold plugin-tests hello
  *
  * @subcommand plugin-tests
  */
 function plugin_tests($args, $assoc_args)
 {
     $wp_filesystem = $this->init_wp_filesystem();
     if (!empty($args[0])) {
         $plugin_slug = $args[0];
         $plugin_dir = WP_PLUGIN_DIR . "/{$plugin_slug}";
     }
     if (!empty($assoc_args['dir'])) {
         $plugin_dir = $assoc_args['dir'];
         if (!is_dir($plugin_dir)) {
             WP_CLI::error('Invalid plugin directory specified.');
         }
         if (empty($plugin_slug)) {
             $plugin_slug = basename($plugin_dir);
         }
     }
     if (empty($plugin_slug) || empty($plugin_dir)) {
         WP_CLI::error('Invalid plugin specified.');
     }
     $tests_dir = "{$plugin_dir}/tests";
     $bin_dir = "{$plugin_dir}/bin";
     $wp_filesystem->mkdir($tests_dir);
     $wp_filesystem->mkdir($bin_dir);
     $this->create_file("{$tests_dir}/bootstrap.php", Utils\mustache_render('bootstrap.mustache', compact('plugin_slug')));
     $to_copy = array('install-wp-tests.sh' => $bin_dir, '.travis.yml' => $plugin_dir, 'phpunit.xml' => $plugin_dir, 'test-sample.php' => $tests_dir);
     foreach ($to_copy as $file => $dir) {
         $wp_filesystem->copy(WP_CLI_ROOT . "/templates/{$file}", "{$dir}/{$file}", true);
         if ('install-wp-tests.sh' === $file) {
             if (!$wp_filesystem->chmod("{$dir}/{$file}", 0755)) {
                 WP_CLI::warning("Couldn't mark install-wp-tests.sh as executable.");
             }
         }
     }
     WP_CLI::success("Created test files.");
 }
开发者ID:dleatherman,项目名称:timbangular-js,代码行数:66,代码来源:scaffold.php

示例5: basename

 /**
  * Generate files needed for running PHPUnit tests.
  *
  * ## OVERVIEW
  *
  * The following files are generated for your plugin by this command:
  *
  * * `phpunit.xml.dist` is the configuration file for PHPUnit.
  * * `.travis.yml` is the configuration file for Travis CI.
  * * `bin/install-wp-tests.sh` configures the WordPress test suite and a test database.
  * * `tests/bootstrap.php` is the file that makes the current plugin active when running the test suite.
  * * `tests/test-sample.php` is a sample file containing the actual tests.
  *
  * Learn more from the [plugin unit tests documentation](http://wp-cli.org/docs/plugin-unit-tests/).
  *
  * ## ENVIRONMENT
  *
  * The `tests/bootstrap.php` file looks for the WP_TESTS_DIR environment
  * variable.
  *
  * ## OPTIONS
  *
  * [<plugin>]
  * : The name of the plugin to generate test files for.
  *
  * [--dir=<dirname>]
  * : Generate test files for a non-standard plugin path. If no plugin slug is specified, the directory name is used.
  *
  * [--force]
  * : Overwrite files that already exist.
  *
  * ## EXAMPLE
  *
  *     wp scaffold plugin-tests hello
  *
  * @subcommand plugin-tests
  */
 function plugin_tests($args, $assoc_args)
 {
     $wp_filesystem = $this->init_wp_filesystem();
     if (!empty($args[0])) {
         $plugin_slug = $args[0];
         $plugin_dir = WP_PLUGIN_DIR . "/{$plugin_slug}";
         if (empty($assoc_args['dir']) && !is_dir($plugin_dir)) {
             WP_CLI::error('Invalid plugin slug specified.');
         }
     }
     if (!empty($assoc_args['dir'])) {
         $plugin_dir = $assoc_args['dir'];
         if (!is_dir($plugin_dir)) {
             WP_CLI::error('Invalid plugin directory specified.');
         }
         if (empty($plugin_slug)) {
             $plugin_slug = basename($plugin_dir);
         }
     }
     if (empty($plugin_slug) || empty($plugin_dir)) {
         WP_CLI::error('Invalid plugin specified.');
     }
     $plugin_name = ucwords(str_replace('-', ' ', $plugin_slug));
     $plugin_package = str_replace(' ', '_', $plugin_name);
     $tests_dir = "{$plugin_dir}/tests";
     $bin_dir = "{$plugin_dir}/bin";
     $wp_filesystem->mkdir($tests_dir);
     $wp_filesystem->mkdir($bin_dir);
     $wp_versions_to_test = array('latest');
     // Parse plugin readme.txt
     if (file_exists($plugin_dir . '/readme.txt')) {
         $readme_content = file_get_contents($plugin_dir . '/readme.txt');
         preg_match('/Requires at least\\:(.*)\\n/m', $readme_content, $matches);
         if (isset($matches[1]) && $matches[1]) {
             $wp_versions_to_test[] = trim($matches[1]);
         }
         preg_match('/Tested up to\\:(.*)\\n/m', $readme_content, $matches);
         if (isset($matches[1]) && $matches[1]) {
             $wp_versions_to_test[] = trim($matches[1]);
         }
     }
     $plugin_data = array('plugin_slug' => $plugin_slug, 'plugin_package' => $plugin_package);
     $force = \WP_CLI\Utils\get_flag_value($assoc_args, 'force');
     $files_written = $this->create_files(array("{$tests_dir}/bootstrap.php" => Utils\mustache_render('bootstrap.mustache', $plugin_data), "{$tests_dir}/test-sample.php" => Utils\mustache_render('test-sample.mustache', $plugin_data), "{$plugin_dir}/.travis.yml" => Utils\mustache_render('.travis.mustache', compact('wp_versions_to_test'))), $force);
     $to_copy = array('install-wp-tests.sh' => $bin_dir, 'phpunit.xml.dist' => $plugin_dir);
     foreach ($to_copy as $file => $dir) {
         $file_name = "{$dir}/{$file}";
         $force = \WP_CLI\Utils\get_flag_value($assoc_args, 'force');
         $should_write_file = $this->prompt_if_files_will_be_overwritten($file_name, $force);
         if (!$should_write_file) {
             continue;
         }
         $files_written[] = $file_name;
         $wp_filesystem->copy(WP_CLI_ROOT . "/templates/{$file}", $file_name, true);
         if ('install-wp-tests.sh' === $file) {
             if (!$wp_filesystem->chmod("{$dir}/{$file}", 0755)) {
                 WP_CLI::warning("Couldn't mark install-wp-tests.sh as executable.");
             }
         }
     }
     $this->log_whether_files_written($files_written, $skip_message = 'All test files were skipped.', $success_message = 'Created test files.');
 }
开发者ID:ryanshoover,项目名称:wp-cli,代码行数:99,代码来源:scaffold.php

示例6: get_global_params

 protected function get_global_params($root_command = false)
 {
     $binding = array();
     $binding['root_command'] = $root_command;
     if (!$this->can_have_subcommands() || is_object($this->parent) && get_class($this->parent) == 'WP_CLI\\Dispatcher\\CompositeCommand') {
         $binding['is_subcommand'] = true;
     }
     foreach (\WP_CLI::get_configurator()->get_spec() as $key => $details) {
         if (false === $details['runtime']) {
             continue;
         }
         if (isset($details['deprecated'])) {
             continue;
         }
         if (isset($details['hidden'])) {
             continue;
         }
         if (true === $details['runtime']) {
             $synopsis = "--[no-]{$key}";
         } else {
             $synopsis = "--{$key}" . $details['runtime'];
         }
         $binding['parameters'][] = array('synopsis' => $synopsis, 'desc' => $details['desc']);
     }
     if ($this->get_subcommands()) {
         $binding['has_subcommands'] = true;
     }
     return Utils\mustache_render('man-params.mustache', $binding);
 }
开发者ID:wesm87,项目名称:wp-cli,代码行数:29,代码来源:CompositeCommand.php

示例7: basename

 /**
  * Generate files needed for running PHPUnit tests.
  *
  * ## DESCRIPTION
  *
  * These are the files that are generated:
  *
  * * `phpunit.xml` is the configuration file for PHPUnit
  * * `.travis.yml` is the configuration file for Travis CI
  * * `tests/bootstrap.php` is the file that makes the current plugin active when running the test suite
  * * `tests/test-sample.php` is a sample file containing the actual tests
  *
  * ## ENVIRONMENT
  *
  * The `tests/bootstrap.php` file looks for the WP_TESTS_DIR environment
  * variable.
  *
  * ## OPTIONS
  *
  * [<plugin>]
  * : The name of the plugin to generate test files for.
  *
  * [--dir=<dirname>]
  * : Generate test files for a non-standard plugin path. If no plugin slug is specified, the directory name is used.
  *
  * [--force]
  * : Overwrite files that already exist.
  *
  * ## EXAMPLE
  *
  *     wp scaffold plugin-tests hello
  *
  * @subcommand plugin-tests
  */
 function plugin_tests($args, $assoc_args)
 {
     $wp_filesystem = $this->init_wp_filesystem();
     if (!empty($args[0])) {
         $plugin_slug = $args[0];
         $plugin_dir = WP_PLUGIN_DIR . "/{$plugin_slug}";
         if (empty($assoc_args['dir']) && !is_dir($plugin_dir)) {
             WP_CLI::error('Invalid plugin slug specified.');
         }
     }
     if (!empty($assoc_args['dir'])) {
         $plugin_dir = $assoc_args['dir'];
         if (!is_dir($plugin_dir)) {
             WP_CLI::error('Invalid plugin directory specified.');
         }
         if (empty($plugin_slug)) {
             $plugin_slug = basename($plugin_dir);
         }
     }
     if (empty($plugin_slug) || empty($plugin_dir)) {
         WP_CLI::error('Invalid plugin specified.');
     }
     $tests_dir = "{$plugin_dir}/tests";
     $bin_dir = "{$plugin_dir}/bin";
     $wp_filesystem->mkdir($tests_dir);
     $wp_filesystem->mkdir($bin_dir);
     $force = \WP_CLI\Utils\get_flag_value($assoc_args, 'force');
     $files_written = $this->create_files(array("{$tests_dir}/bootstrap.php" => Utils\mustache_render('bootstrap.mustache', compact('plugin_slug'))), $force);
     $to_copy = array('install-wp-tests.sh' => $bin_dir, '.travis.yml' => $plugin_dir, 'phpunit.xml' => $plugin_dir, 'test-sample.php' => $tests_dir);
     foreach ($to_copy as $file => $dir) {
         $file_name = "{$dir}/{$file}";
         $force = \WP_CLI\Utils\get_flag_value($assoc_args, 'force');
         $should_write_file = $this->prompt_if_files_will_be_overwritten($file_name, $force);
         if (!$should_write_file) {
             continue;
         }
         $files_written[] = $file_name;
         $wp_filesystem->copy(WP_CLI_ROOT . "/templates/{$file}", $file_name, true);
         if ('install-wp-tests.sh' === $file) {
             if (!$wp_filesystem->chmod("{$dir}/{$file}", 0755)) {
                 WP_CLI::warning("Couldn't mark install-wp-tests.sh as executable.");
             }
         }
     }
     $this->log_whether_files_written($files_written, $skip_message = 'All test files were skipped.', $success_message = 'Created test files.');
 }
开发者ID:brianedsauer,项目名称:wp-cli,代码行数:80,代码来源:scaffold.php

示例8: compact

 /**
  * Generate files needed for running PHPUnit tests.
  *
  * ## DESCRIPTION
  *
  * These are the files that are generated:
  *
  * * `phpunit.xml` is the configuration file for PHPUnit
  * * `.travis.yml` is the configuration file for Travis CI
  * * `tests/bootstrap.php` is the file that makes the current plugin active when running the test suite
  * * `tests/test-sample.php` is a sample file containing the actual tests
  *
  * ## ENVIRONMENT
  *
  * The `tests/bootstrap.php` file looks for the WP_TESTS_DIR environment
  * variable.
  *
  * ## OPTIONS
  *
  * <plugin>
  * : The name of the plugin to generate test files for.
  *
  * ## EXAMPLE
  *
  *     wp scaffold plugin-tests hello
  *
  * @subcommand plugin-tests
  */
 function plugin_tests($args, $assoc_args)
 {
     global $wp_filesystem;
     $plugin_slug = $args[0];
     $plugin_dir = WP_PLUGIN_DIR . "/{$plugin_slug}";
     $tests_dir = "{$plugin_dir}/tests";
     $bin_dir = "{$plugin_dir}/bin";
     $wp_filesystem->mkdir($tests_dir);
     $wp_filesystem->mkdir($bin_dir);
     $this->create_file("{$tests_dir}/bootstrap.php", Utils\mustache_render('bootstrap.mustache', compact('plugin_slug')));
     $to_copy = array('install-wp-tests.sh' => $bin_dir, '.travis.yml' => $plugin_dir, 'phpunit.xml' => $plugin_dir, 'test-sample.php' => $tests_dir);
     foreach ($to_copy as $file => $dir) {
         $wp_filesystem->copy(WP_CLI_ROOT . "/templates/{$file}", "{$dir}/{$file}", true);
     }
     WP_CLI::success("Created test files.");
 }
开发者ID:nb,项目名称:wp-cli,代码行数:44,代码来源:scaffold.php

示例9: scaffold_plugin_theme_tests

 private function scaffold_plugin_theme_tests($args, $assoc_args, $type)
 {
     $wp_filesystem = $this->init_wp_filesystem();
     if (!empty($args[0])) {
         $slug = $args[0];
         if ('theme' === $type) {
             $theme = wp_get_theme($slug);
             if ($theme->exists()) {
                 $target_dir = $theme->get_stylesheet_directory();
             } else {
                 WP_CLI::error("Invalid {$type} slug specified.");
             }
         } else {
             $target_dir = WP_PLUGIN_DIR . "/{$slug}";
         }
         if (empty($assoc_args['dir']) && !is_dir($target_dir)) {
             WP_CLI::error("Invalid {$type} slug specified.");
         }
     }
     if (!empty($assoc_args['dir'])) {
         $target_dir = $assoc_args['dir'];
         if (!is_dir($target_dir)) {
             WP_CLI::error("Invalid {$type} directory specified.");
         }
         if (empty($slug)) {
             $slug = basename($target_dir);
         }
     }
     if (empty($slug) || empty($target_dir)) {
         WP_CLI::error("Invalid {$type} specified.");
     }
     $name = ucwords(str_replace('-', ' ', $slug));
     $package = str_replace(' ', '_', $name);
     $tests_dir = "{$target_dir}/tests";
     $bin_dir = "{$target_dir}/bin";
     $wp_filesystem->mkdir($tests_dir);
     $wp_filesystem->mkdir($bin_dir);
     $wp_versions_to_test = array('latest');
     // Parse plugin readme.txt
     if (file_exists($target_dir . '/readme.txt')) {
         $readme_content = file_get_contents($target_dir . '/readme.txt');
         preg_match('/Requires at least\\:(.*)\\n/m', $readme_content, $matches);
         if (isset($matches[1]) && $matches[1]) {
             $wp_versions_to_test[] = trim($matches[1]);
         }
         preg_match('/Tested up to\\:(.*)\\n/m', $readme_content, $matches);
         if (isset($matches[1]) && $matches[1]) {
             $wp_versions_to_test[] = trim($matches[1]);
         }
     }
     $template_data = array("{$type}_slug" => $slug, "{$type}_package" => $package);
     $force = \WP_CLI\Utils\get_flag_value($assoc_args, 'force');
     $files_to_create = array("{$tests_dir}/bootstrap.php" => Utils\mustache_render("{$type}-bootstrap.mustache", $template_data), "{$tests_dir}/test-sample.php" => Utils\mustache_render("{$type}-test-sample.mustache", $template_data));
     if ('travis' === $assoc_args['ci']) {
         $files_to_create["{$target_dir}/.travis.yml"] = Utils\mustache_render('plugin-travis.mustache', compact('wp_versions_to_test'));
     } else {
         if ('circle' === $assoc_args['ci']) {
             $files_to_create["{$target_dir}/circle.yml"] = Utils\mustache_render('plugin-circle.mustache');
         } else {
             if ('gitlab' === $assoc_args['ci']) {
                 $files_to_create["{$target_dir}/.gitlab-ci.yml"] = Utils\mustache_render('plugin-gitlab.mustache');
             }
         }
     }
     $files_written = $this->create_files($files_to_create, $force);
     $to_copy = array('install-wp-tests.sh' => $bin_dir, 'phpunit.xml.dist' => $target_dir, 'phpcs.ruleset.xml' => $target_dir);
     foreach ($to_copy as $file => $dir) {
         $file_name = "{$dir}/{$file}";
         $force = \WP_CLI\Utils\get_flag_value($assoc_args, 'force');
         $should_write_file = $this->prompt_if_files_will_be_overwritten($file_name, $force);
         if (!$should_write_file) {
             continue;
         }
         $files_written[] = $file_name;
         $wp_filesystem->copy(WP_CLI_ROOT . "/templates/{$file}", $file_name, true);
         if ('install-wp-tests.sh' === $file) {
             if (!$wp_filesystem->chmod("{$dir}/{$file}", 0755)) {
                 WP_CLI::warning("Couldn't mark 'install-wp-tests.sh' as executable.");
             }
         }
     }
     $this->log_whether_files_written($files_written, $skip_message = 'All test files were skipped.', $success_message = 'Created test files.');
 }
开发者ID:wp-cli,项目名称:wp-cli,代码行数:83,代码来源:scaffold.php


注:本文中的WP_CLI\Utils\mustache_render函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。