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


PHP Timber::fetch方法代码示例

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


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

示例1: add

 public function add($attributes)
 {
     if (empty($attributes['ids'])) {
         return;
     }
     $context['gallery'] = array_map(function ($item) {
         return new \TimberImage($item->ID);
     }, get_posts(['include' => $attributes['ids'], 'post_mime_type' => 'image', 'post_status' => 'inherit', 'post_type' => 'attachment', 'order' => 'ASC', 'orderby' => 'post__in']));
     return \Timber::fetch('partials/gallery.twig', $context);
 }
开发者ID:trendwerk,项目名称:trendpress,代码行数:10,代码来源:Gallery.php

示例2: extra_user_profile_fields

 /**
  * This functions enables the new user fields on backend
  *
  * @param WP_User $user User to get information from.
  */
 function extra_user_profile_fields($user)
 {
     $admin_template = get_stylesheet_directory() . '/templates/admin/sc-user.twig';
     foreach ($this->custom_user_fields as $user_field) {
         $options['name'] = $user_field['name'];
         $options['available_values'] = $this->get_info_for_select($user_field['post_type']);
         $options['stored_values'] = get_user_meta($user->ID, $user_field['name'], true);
     }
     $section_html_content = Timber::fetch($admin_template, array('options' => $options));
     echo $section_html_content;
 }
开发者ID:softcatala,项目名称:wp-softcatala,代码行数:16,代码来源:user.php

示例3: throw_error

            throw_error('500', 'Error connecting to API server');
            $context_holder['cerca_result'] = 'S\'ha produït un error en contactar amb el servidor. Proveu de nou.';
        }
    }
} else {
    if (!empty($lletra)) {
        if (strlen($lletra) == '1') {
            $url = $url_api . 'index/' . $lletra;
            $api_response = json_decode(do_json_api_call($url));
            if ($api_response) {
                $response['lletra'] = $lletra;
                $response['result'] = $api_response;
                $title = 'Diccionari multilingüe: paraules que comencen per ' . $lletra;
                $content_title = 'Diccionari multilingüe. Lletra «' . $lletra . '»';
                $canonical = '/diccionari-multilingue/lletra/' . $lletra . '/';
                $context_holder['cerca_result'] = Timber::fetch('ajax/multilingue-lletra.twig', array('response' => $response));
            } else {
                throw_error('500', 'Error connecting to API server');
                $context_holder['cerca_result'] = 'S\'ha produït un error en contactar amb el servidor. Proveu de nou.';
            }
        } else {
            throw_error('404', 'No Results For This Search');
            $context_holder['cerca_result'] = 'Esteu utilitzant la cerca per lletra. Heu cercat <strong>' . $context['lletra'] . '</strong>. La cerca només pot contenir una lletra';
        }
    }
}
$context_filterer = new SC_ContextFilterer($context_holder);
$context_overrides = array('title' => $title, 'description' => $description, 'canonical' => $canonical);
$context = $context_filterer->get_filtered_context($context_overrides, false);
$context['post'] = $post;
$context['paraula'] = $paraula;
开发者ID:softcatala,项目名称:wp-softcatala,代码行数:31,代码来源:diccionari-multilingue.php

示例4: softcatala_dash_page

 /**
  * Renders the Softcatalà dashboard settings page
  */
 function softcatala_dash_page()
 {
     wp_enqueue_script('sc-js-dash', get_template_directory_uri() . '/static/js/sc-admin.js', array('jquery'), WP_SOFTCATALA_VERSION, true);
     $admin_template = dirname(__FILE__) . '/templates/admin/sc-dash.twig';
     $sections = $this->get_email_sections();
     $section_html_content = Timber::fetch($admin_template, array('sections' => $sections));
     echo $section_html_content;
 }
开发者ID:softcatala,项目名称:wp-softcatala,代码行数:11,代码来源:functions.php

示例5: scimporter_dash_page

 /**
  * Renders the dashboard page
  */
 function scimporter_dash_page()
 {
     $admin_template = dirname(__FILE__) . '/templates/admin/sc-importer.twig';
     $section_html_content = Timber::fetch($admin_template);
     echo $section_html_content;
 }
开发者ID:softcatala,项目名称:sc-importer,代码行数:9,代码来源:sc-importer.php

示例6: sc_search_program

/**
 * Function to look up a program with a title similar to the title from the search on the add program form
 *
 * @return json response
 */
function sc_search_program()
{
    if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], $_POST["action"])) {
        $result['text'] = "S'ha produït un error en cercar el programa. Podeu continuar igualment.";
    } else {
        check_is_ajax_call();
        $nom_programa = sanitize_text_field($_POST["nom_programa"]);
        $result = array();
        if (!empty($nom_programa)) {
            $query['s'] = $nom_programa;
            $args = get_post_query_args('programa', SearchQueryType::Programa, $query);
            $result_full = query_posts($args);
        }
        $programs = array_map('generate_post_url_link', $result_full);
        if (count($programs) > 0) {
            $result['programs'] = Timber::fetch('ajax/programs-list.twig', array('programs' => $programs));
            $result['text'] = "El programa que proposeu és algun dels que es mostren a continuació?";
        } else {
            $result['text'] = "El programa no està a la nostra base de dades. Podeu continuar!";
        }
    }
    $response = json_encode($result);
    die($response);
}
开发者ID:softcatala,项目名称:wp-softcatala,代码行数:29,代码来源:ajax_operations.php

示例7: generate_ads_html

//Ads
$context_holder['ads_container'] = generate_ads_html(array('13', '17'));
$paraula = sanitize_text_field(urldecode(get_query_var('paraula')));
$content_title = 'Diccionari de sinònims';
if (!empty($paraula)) {
    $url = $url_sinonims_server . urlencode($paraula);
    try {
        $sinonims_server = json_decode(do_json_api_call($url));
        if ($sinonims_server != 'error' && count($sinonims_server->synsets) > 0) {
            $sinonims['paraula'] = $paraula;
            $sinonims['response'] = $sinonims_server->synsets;
            $content_title = 'Diccionari de sinònims: «' . $paraula . '»';
            $title = 'Diccionari de sinònims en català: «' . $paraula . '»';
            $prefix_description = 'Sinònims de «' . $paraula . '» en català.';
            $canonical = get_current_url();
            $context_holder['sinonims_result'] = Timber::fetch('ajax/sinonims-list.twig', array('sinonims' => $sinonims));
        } else {
            if ($sinonims_server == 'error') {
                throw_service_error($content_title);
            } else {
                throw_error('404', 'No Results For This Search');
                $context_holder['sinonims_result'] = 'La paraula que esteu cercant no es troba al diccionari.';
            }
        }
    } catch (Exception $e) {
        throw_service_error($content_title);
    }
}
$context_overrides = array('title' => $title, 'prefix_description' => $prefix_description, 'canonical' => $canonical);
$context_filterer = new SC_ContextFilterer($context_holder);
$context = $context_filterer->get_filtered_context($context_overrides, false);
开发者ID:softcatala,项目名称:wp-softcatala,代码行数:31,代码来源:sinonims.php


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