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


PHP Arr::iterable方法代码示例

本文整理汇总了PHP中Arr::iterable方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::iterable方法的具体用法?PHP Arr::iterable怎么用?PHP Arr::iterable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Arr的用法示例。


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

示例1: sendEmailer

 public static function sendEmailer($to, $emailer, $debug = false)
 {
     if (!$to) {
         return false;
     }
     if (!Arr::iterable($emailer)) {
         return false;
     }
     $mail = new PHPMailer();
     $mail->Port = 1025;
     $mail->setFrom($emailer['from']);
     $mail->addReplyTo($emailer['from']);
     $mail->addAddress($to);
     $mail->isHTML(true);
     $mail->Subject = $emailer['subject'];
     $mail->Body = $emailer['rendered_template'];
     $did_it_send = $mail->send();
     if ($debug) {
         if ($did_it_send) {
             echo 'Message could not be sent.';
             echo 'Mailer Error: ' . $mail->ErrorInfo;
         } else {
             echo 'Message has been sent';
         }
         exit;
     }
 }
开发者ID:tacowordpress,项目名称:taco-2016-boilerplate,代码行数:27,代码来源:Emailer.php

示例2: app_enqueue_script

/**
 * Enqueue the JS
 * @param bool $is_admin
 * @param array $scripts
 */
function app_enqueue_script($is_admin = false)
{
    $scripts = $is_admin ? app_admin_get_js() : app_get_js();
    if (!Arr::iterable($scripts)) {
        return;
    }
    $template_directory = get_template_directory_uri();
    foreach ($scripts as $key => $script) {
        $path = preg_match('/^(https?\\:|\\/\\/)/', $script) ? $script : $template_directory . '/' . $script;
        wp_deregister_script($key);
        wp_register_script($key, $path, false, THEME_VERSION, true);
        wp_enqueue_script($key);
    }
}
开发者ID:tacowordpress,项目名称:taco-theme,代码行数:19,代码来源:functions-generic.php

示例3: make

 /**
  * Include file with scoped variables
  * @param string $path
  * @param array $variables
  * @param bool $include_once
  * @param bool $die_on_error
  */
 public static function make($path, $variables = [], $include_once = false, $die_on_error = false)
 {
     $view_path = self::find($path, $die_on_error);
     if (Arr::iterable($variables)) {
         extract($variables);
     }
     ob_start();
     if ($include_once) {
         include_once $view_path;
     } else {
         include $view_path;
     }
     return ob_get_clean();
 }
开发者ID:tacowordpress,项目名称:util,代码行数:21,代码来源:View.php

示例4: selecty

 /**
  * Get a select list
  * @param array $options
  * @param string $selected
  * @param array $attribs
  * @return string
  */
 public static function selecty($options, $selected = null, $attribs = array())
 {
     $htmls = array();
     $htmls[] = self::select(null, $attribs, false);
     if (Arr::iterable($options)) {
         foreach ($options as $value => $title) {
             $option_attribs = array('value' => $value);
             if ((string) $selected === (string) $value) {
                 $option_attribs['selected'] = 'selected';
             }
             $htmls[] = self::option($title, $option_attribs);
         }
     }
     $htmls[] = '</select>';
     return join("\n", $htmls);
 }
开发者ID:quasel,项目名称:tacowordpress,代码行数:23,代码来源:Html.php

示例5: get_edit_link

/**
 * Get edit link when admin is logged in
 * @param int $id (post ID or term ID)
 * @param string $edit_type (post type or taxonomy slug)
 * @param string $label (optional admin-facing name for $edit_type)
 * @param bool $display_inline (omit wrapping paragraph)
 * @return string (HTML)
 */
function get_edit_link($id = null, $edit_type = 'post', $label = null, $display_inline = false)
{
    if (!(is_user_logged_in() && current_user_can('manage_options'))) {
        return null;
    }
    $link_class = 'class="front-end-edit-link"';
    $link_tag = $display_inline ? 'span' : 'p';
    if (is_null($label)) {
        $label = Str::human(str_replace('-', ' ', $edit_type));
    }
    $subclasses = \Taco\Post\Loader::getSubclasses();
    $subclasses_machine = array_map(function ($el) {
        $el = substr($el, strrpos($el, '\\'));
        $el = Str::camelToHuman($el);
        $el = Str::machine($el, '-');
        return $el;
    }, $subclasses);
    if (in_array($edit_type, $subclasses_machine)) {
        // Edit post or display list of posts of this type
        $post_type_link = !is_null($id) ? get_edit_post_link($id) : '/wp-admin/edit.php?post_type=' . $edit_type;
        return sprintf('<%s %s><a href="%s">Edit %s</a></%s>', $link_tag, $link_class, $post_type_link, $label, $link_tag);
    }
    // Find an applicable post type for editing a custom term
    $post_type = null;
    $post_types_by_taxonomy = [];
    foreach ($subclasses as $subclass) {
        if (strpos($subclass, '\\') !== false) {
            $subclass = '\\' . $subclass;
        }
        $taxonomies = \Taco\Post\Factory::create($subclass)->getTaxonomies();
        if (Arr::iterable($taxonomies)) {
            foreach ($taxonomies as $key => $taxonomy) {
                $taxonomy_slug = is_array($taxonomy) ? $key : $taxonomy;
                $post_types_by_taxonomy[$taxonomy_slug][] = $subclass;
            }
        }
    }
    $post_types_by_taxonomy = array_unique($post_types_by_taxonomy);
    if (array_key_exists($edit_type, $post_types_by_taxonomy)) {
        $post_type = reset($post_types_by_taxonomy[$edit_type]);
        $post_type = substr($post_type, strrpos($post_type, '\\'));
        $post_type = Str::camelToHuman($post_type);
        $post_type = Str::machine($post_type, '-');
    } else {
        $post_type = 'post';
    }
    if (is_null($id)) {
        // View taxonomy term list
        return sprintf('<%s %s><a href="/wp-admin/edit-tags.php?taxonomy=%s&post_type=%s">View %ss</a></%s>', $link_tag, $link_class, $edit_type, $post_type, $label, $link_tag);
    }
    // Edit term
    return sprintf('<%s %s><a href="%s">Edit %s</a></%s>', $link_tag, $link_class, get_edit_term_link($id, $edit_type, $post_type), $label, $link_tag);
}
开发者ID:tacowordpress,项目名称:taco-theme,代码行数:61,代码来源:functions-app.php

示例6: sanitizeIDs

 /**
  * Sanitize a list of numeric IDs, and return the same format
  * @param array/string $ids (array or comma-separated list)
  * @return array/string (same as input type)
  */
 public static function sanitizeIDs($ids)
 {
     if (!is_array($ids)) {
         $return_string = true;
         $ids = explode(',', $ids);
     }
     if (!Arr::iterable($ids)) {
         return false;
     }
     $ids = array_map('trim', $ids);
     $ids = array_filter($ids, 'strlen');
     $ids = array_map('intval', $ids);
     $ids = array_map('abs', $ids);
     return $return_string ? join(',', $ids) : $ids;
 }
开发者ID:tacowordpress,项目名称:util,代码行数:20,代码来源:Num.php

示例7: app_enqueue_script

/**
 * Enqueue the JS
 */
function app_enqueue_script()
{
    $scripts = app_get_js();
    if (!Arr::iterable($scripts)) {
        return;
    }
    foreach ($scripts as $k => $script) {
        wp_deregister_script($k);
        wp_register_script($k, get_template_directory_uri() . '/' . $script, false, THEME_VERSION, true);
        wp_enqueue_script($k);
    }
}
开发者ID:vermiliondesign,项目名称:taco_boilerplate_2015_no_symlinks,代码行数:15,代码来源:functions-generic.php

示例8: getBreadcrumbs

 /**
  * Get breadcrumbs HTML
  * @param \Taco\Post $post_obj
  * @return string HTML
  */
 public static function getBreadcrumbs(\Taco\Post $post_obj)
 {
     $separator = ' &raquo; ';
     $post_id = $post_obj->get('ID');
     $post_type = $post_obj->getPostType();
     $ancestor_links = array();
     $post_title = null;
     if (is_archive()) {
         // This is the blog archive, what to do for breadcrumbs here?
         return null;
     }
     if ($post_type == 'page') {
         $post_title = $post_obj->getTheTitle();
         $ancestors = get_post_ancestors($post_id);
         if (Arr::iterable($ancestors)) {
             $ancestors = array_reverse($ancestors);
             foreach ($ancestors as $ancestor_post_id) {
                 $ancestor = \Taco\Post\Factory::create($ancestor_post_id, false);
                 $single_post = get_post($post_id);
                 $ancestor_links[] = sprintf('<li><a href="%s">%s</a></li>', $ancestor->getPermalink(), $ancestor->getTheTitle());
             }
         }
     } elseif ($post_type == 'article') {
         $ancestor_links[] = '<li><a href="' . URL_NEWS . '">News</a></li>';
         $topics = $post_obj->getTerms('topic');
         if (Arr::iterable($topics)) {
             $topic = reset($topics);
             $ancestor_links[] = sprintf('<li><a href="%s">%s</a></li>', $topic->getPermalink(), $topic->get('name'));
         }
     }
     // Don't display breadcrumbs unless there's at least one ancestor
     if (!Arr::iterable($ancestor_links)) {
         return null;
     }
     return sprintf('<ul class="bread-crumbs">
     %s
     <li>%s</li>
   </ul>', join('', $ancestor_links), $post_title);
 }
开发者ID:tacowordpress,项目名称:taco-2016-boilerplate,代码行数:44,代码来源:Util.php

示例9: foreach

                echo $t->slug;
                ?>
</li>
            <?php 
            }
            ?>
          </ul>
        <?php 
        }
        ?>

        <?php 
        $terms = $r->getTerms('resource-topic');
        ?>
        <?php 
        if (Arr::iterable($terms)) {
            ?>
          <strong>Resource Topic</strong><br>
          <ul>
            <?php 
            foreach ($terms as $t) {
                ?>
              <li><?php 
                echo $t->slug;
                ?>
</li>
            <?php 
            }
            ?>
          </ul>
        <?php 
开发者ID:tacowordpress,项目名称:taco-2016-boilerplate,代码行数:31,代码来源:tmpl-resources.php


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