本文整理汇总了PHP中__函数的典型用法代码示例。如果您正苦于以下问题:PHP __函数的具体用法?PHP __怎么用?PHP __使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了__函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: genesis_404
/**
* This function outputs a 404 "Not Found" error message
*
* @since 1.6
*/
function genesis_404()
{
echo genesis_html5() ? '<article class="entry">' : '<div class="post hentry">';
printf('<h1 class="entry-title">%s</h1>', apply_filters('genesis_404_entry_title', __('Not found, error 404', 'genesis')));
echo '<div class="entry-content">';
if (genesis_html5()) {
echo apply_filters('genesis_404_entry_content', '<p>' . sprintf(__('The page you are looking for no longer exists. Perhaps you can return back to the site\'s <a href="%s">homepage</a> and see if you can find what you are looking for. Or, you can try finding it by using the search form below.', 'genesis'), trailingslashit(home_url())) . '</p>');
get_search_form();
} else {
?>
<p><?php
printf(__('The page you are looking for no longer exists. Perhaps you can return back to the site\'s <a href="%s">homepage</a> and see if you can find what you are looking for. Or, you can try finding it with the information below.', 'genesis'), trailingslashit(home_url()));
?>
</p>
<?php
}
if (!genesis_html5()) {
genesis_sitemap('h4');
} elseif (genesis_a11y('404-page')) {
echo '<h2>' . __('Sitemap', 'genesis') . '</h2>';
genesis_sitemap('h3');
}
echo '</div>';
echo genesis_html5() ? '</article>' : '</div>';
}
示例2: _pb_minimum_wp
/**
* Echo message about minimum WordPress Version
*/
function _pb_minimum_wp()
{
global $pb_minimum_wp;
echo '<div id="message" class="error fade"><p>';
printf(__('Pressbooks will not work with your version of WordPress. Pressbooks requires a dedicated install of WordPress Multi-Site, version %s or greater. Please upgrade WordPress if you would like to use Pressbooks.', 'pressbooks'), $pb_minimum_wp);
echo '</p></div>';
}
示例3: destroy
function destroy($id)
{
$param = array('conditions' => array('id' => $id));
$enumeration = $this->Enumeration->find('first', $param);
$this->set('options', $this->Enumeration->OPTIONS);
$this->set('enumeration', $enumeration);
$count = $this->Enumeration->objects_count($enumeration);
$this->set('objects_count', $count);
if ($count == 0) {
# No associated objects
if ($this->Enumeration->del($id)) {
$this->Session->setFlash(__('Successful update.', true), 'default', array('class' => 'flash flash_notice'));
$this->redirect('index');
}
} else {
if (isset($this->data['Enumeration']['reassign_to_id'])) {
# if reassign_to = Enumeration.find_by_opt_and_id(@enumeration.opt, params[:reassign_to_id])
$this->Enumeration->destroy($enumeration, $this->data['Enumeration']['reassign_to_id']);
$this->redirect('index');
# end
}
}
$this->set('enumerations', $this->Enumeration->get_values($enumeration['Enumeration']['opt']));
# #rescue
# # flash[:error] = 'Unable to delete enumeration'
# # redirect_to :action => 'index'
}
示例4: normalize_field
/**
* Add default value for 'taxonomy' field
*
* @param $field
*
* @return array
*/
static function normalize_field($field)
{
$default_args = array('hide_empty' => false);
// Set default args
$field['options']['args'] = !isset($field['options']['args']) ? $default_args : wp_parse_args($field['options']['args'], $default_args);
$tax = get_taxonomy($field['options']['taxonomy']);
$field['placeholder'] = empty($field['placeholder']) ? sprintf(__('Select a %s', 'framework'), $tax->labels->singular_name) : $field['placeholder'];
switch ($field['options']['type']) {
case 'select_advanced':
$field = RWMB_Select_Advanced_Field::normalize_field($field);
break;
case 'checkbox_list':
case 'checkbox_tree':
$field = RWMB_Checkbox_List_Field::normalize_field($field);
break;
case 'select':
case 'select_tree':
$field = RWMB_Select_Field::normalize_field($field);
break;
default:
$field['options']['type'] = 'select';
$field = RWMB_Select_Field::normalize_field($field);
}
if (in_array($field['options']['type'], array('checkbox_tree', 'select_tree'))) {
if (isset($field['options']['args']['parent'])) {
$field['options']['parent'] = $field['options']['args']['parent'];
unset($field['options']['args']['parent']);
} else {
$field['options']['parent'] = 0;
}
}
$field['field_name'] = "{$field['id']}[]";
return $field;
}
示例5: execute
/**
* Save action
*
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
$data = $this->getRequest()->getPostValue();
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
if ($data) {
$model = $this->_objectManager->create('OsmanSorkar\\Blog\\Model\\Category');
$id = $this->getRequest()->getParam('cat_id');
if ($id) {
$model->load($id);
}
$model->setData($data);
$this->_eventManager->dispatch('blog_category_prepare_save', ['post' => $model, 'request' => $this->getRequest()]);
try {
$model->save();
$this->messageManager->addSuccess(__('You saved this Category.'));
$this->_objectManager->get('Magento\\Backend\\Model\\Session')->setFormData(false);
if ($this->getRequest()->getParam('back')) {
return $resultRedirect->setPath('*/*/edit', ['cat_id' => $model->getId(), '_current' => true]);
}
return $resultRedirect->setPath('*/*/');
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
} catch (\RuntimeException $e) {
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addException($e, __('Something went wrong while saving the page.'));
}
$this->_getSession()->setFormData($data);
return $resultRedirect->setPath('*/*/edit', ['cat_id' => $this->getRequest()->getParam('cat_id')]);
}
return $resultRedirect->setPath('*/*/');
}
示例6: _toHtml
/**
* Generate RSS XML with sales rules data
*
* @return string
*/
protected function _toHtml()
{
$storeId = $this->_getStoreId();
$storeModel = $this->_storeManager->getStore($storeId);
$websiteId = $storeModel->getWebsiteId();
$customerGroup = $this->_getCustomerGroupId();
$now = date('Y-m-d');
$url = $this->_urlBuilder->getUrl('');
$newUrl = $this->_urlBuilder->getUrl('rss/catalog/salesrule');
$title = __('%1 - Discounts and Coupons', $storeModel->getName());
$lang = $this->_scopeConfig->getValue('general/locale/code', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeModel);
/** @var $rssObject \Magento\Rss\Model\Rss */
$rssObject = $this->_rssFactory->create();
$rssObject->_addHeader(array('title' => $title, 'description' => $title, 'link' => $newUrl, 'charset' => 'UTF-8', 'language' => $lang));
/** @var $collection \Magento\SalesRule\Model\Resource\Rule\Collection */
$collection = $this->_collectionFactory->create();
$collection->addWebsiteGroupDateFilter($websiteId, $customerGroup, $now)->addFieldToFilter('is_rss', 1)->setOrder('from_date', 'desc');
$collection->load();
/** @var $ruleModel \Magento\SalesRule\Model\Rule */
foreach ($collection as $ruleModel) {
$description = '<table><tr>' . '<td style="text-decoration:none;">' . $ruleModel->getDescription() . '<br/>Discount Start Date: ' . $this->formatDate($ruleModel->getFromDate(), 'medium');
if ($ruleModel->getToDate()) {
$description .= '<br/>Discount End Date: ' . $this->formatDate($ruleModel->getToDate(), 'medium');
}
if ($ruleModel->getCouponCode()) {
$description .= '<br/> Coupon Code: ' . $ruleModel->getCouponCode();
}
$description .= '</td></tr></table>';
$rssObject->_addEntry(array('title' => $ruleModel->getName(), 'description' => $description, 'link' => $url));
}
return $rssObject->createRssXml();
}
示例7: Services_meta
public function Services_meta()
{
$Services_meta = array('id' => 'Services_section', 'title' => __('Home Page Additional Information', 'SimThemes'), 'desc' => '', 'pages' => array('Service'), 'context' => 'normal', 'priority' => 'high', 'fields' => array(array('id' => 'service_icon', 'label' => __('Service Icon', 'SimThemes'), 'desc' => sprintf(__('Please select the icon', 'SimThemes')), 'std' => '', 'type' => 'font-awesome', 'section' => 'option_types', 'rows' => '', 'post_type' => '', 'taxonomy' => '', 'min_max_step' => '', 'class' => ''), array('id' => 'client_Email', 'label' => __('Clint Email', 'SimThemes'), 'desc' => '', 'std' => '', 'type' => 'text', 'section' => 'option_types', 'rows' => '', 'post_type' => '', 'taxonomy' => '', 'min_max_step' => '', 'class' => '', 'operator' => 'and'), array('id' => 'client_Designation', 'label' => __('Clint Designation', 'SimThemes'), 'desc' => '', 'std' => '', 'type' => 'text', 'section' => 'option_types', 'rows' => '', 'post_type' => '', 'taxonomy' => '', 'min_max_step' => '', 'class' => '', 'operator' => 'and')));
if (function_exists('ot_register_meta_box')) {
ot_register_meta_box($Services_meta);
}
}
示例8: addUsedInRecommender
/**
* Adds 'used_in_recommender' form field
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function addUsedInRecommender(\Magento\Framework\Event\Observer $observer)
{
/** @var \Magento\Framework\Data\Form $form */
$form = $observer->getEvent()->getForm();
$fieldset = $form->getElement('advanced_fieldset');
$fieldset->addField('used_in_recommender', 'select', ['name' => 'used_in_recommender', 'label' => __('Used in Recommender'), 'title' => __('Used in Recommender (Exported to the recommender system)'), 'note' => __('Exported to the recommender system'), 'values' => $this->_yesNo->toOptionArray()]);
}
示例9: setUp
public function setUp()
{
/**
* Adds setting fields in the meta box.
*/
$this->addSettingFields(array('field_id' => '_dgx_donate_fund_show', 'title' => __('Display on donation form', 'seamless-donations'), 'type' => 'radio', 'label' => array('Yes' => 'Yes', 'No' => 'No'), 'default' => 'Yes', 'description' => __('If you select Yes, this fund will be shown on the front-end donation form.' . '<br>If you select No, this fund will not be shown on the donation form.', 'seamless-donations')));
}
示例10: widget
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? __('Pages') : $instance['title']);
$sortby = empty($instance['sortby']) ? 'menu_order' : $instance['sortby'];
$exclude = empty($instance['exclude']) ? '' : $instance['exclude'];
if ($sortby == 'post_date') {
$showdate = "created";
}
if ($sortby == 'menu_order') {
$sortby = 'menu_order, post_title, post_date';
}
$out = wp_list_pages(apply_filters('widget_pages_args', array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude, 'show_date' => $showdate)));
if (!empty($out)) {
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
?>
<ul>
<?php
echo $out;
?>
</ul>
<?php
echo $after_widget;
}
}
示例11: pitch_add_slide_metabox
/**
* Set up the placeholder metaboxes for Pitch's slide
*/
function pitch_add_slide_metabox()
{
if (defined('SITEORIGIN_IS_PREMIUM')) {
return;
}
add_meta_box('pitch_slide_destination', __('Destination', 'pitch'), 'pitch_slide_destination_metabox', 'slide', 'side');
}
示例12: sp_init_bp_special_tags
function sp_init_bp_special_tags()
{
global $special_tags;
/*
* Buddypress components
*/
$special_tags->add_tag('%%component_name%%', 'sp_get_bp_current_component', __('Shows the component name', 'seopress'));
$special_tags->add_set('bp_component', array('%%component_name%%'));
/*
* Buddypress activities
*/
$special_tags->add_tag('%%activity_content%%', 'sp_get_bp_activity_content', __('Shows the content of the activity', 'seopress'));
$special_tags->add_tag('%%activity_author%%', 'sp_get_bp_activity_author', __('Shows the author of the activity', 'seopress'));
$special_tags->add_set('bp_activity', array('%%activity_content%%', '%%activity_author%%'));
/*
* Buddypress groups
*/
$special_tags->add_tag('%%group%%', 'sp_get_bp_group_name', __('Shows the group name', 'seopress'));
$special_tags->add_tag('%%group_description%%', 'sp_get_bp_group_description', __('Shows the group description', 'seopress'));
$special_tags->add_set('bp_group', array('%%group%%', '%%group_description%%'));
/*
* Buddypress users
*/
$special_tags->add_tag('%%user_name%%', 'sp_get_bp_user_display_name', __('Shows name of the user', 'seopress'));
$special_tags->add_set('bp_user', array('%%user_name%%'));
/*
* Buddypress forums
*/
// sp_add_special_tag( 'bp_forum' , '%%forumname%%', 'sp_get_bp_group_name', __( 'Shows the forum name' , 'seopress') ); // Has it a name ???
$special_tags->add_tag('%%forum_topic_title%%', 'sp_get_bp_forum_topic_title', __('Shows the forum topic title', 'seopress'));
$special_tags->add_tag('%%forum_topic_text%%', 'sp_get_bp_forum_post_text', __('Shows the forum topic text', 'seopress'));
$special_tags->add_tag('%%forum_topic_author%%', 'sp_get_bp_forum_topic_poster_name', __('Shows the forum topic poster name', 'seopress'));
$special_tags->add_set('bp_forum_topic', array('%%forum_topic_title%%', '%%forum_topic_text%%', '%%forum_topic_author%%'));
}
示例13: wt_warnings
/**
* Check if users need to set the file permissions in order to support the theme, and if not, displays warnings messages in admin option page.
*/
function wt_warnings()
{
global $wp_version;
$warnings = array();
if (!wt_check_wp_version()) {
$warnings[] = 'Wordpress version(<b>' . $wp_version . '</b>) is too low. Please upgrade to the latest version.';
}
if (!function_exists("imagecreatetruecolor")) {
$warnings[] = 'GD Library Error: <b>imagecreatetruecolor does not exist</b>. Please contact your host provider and ask them to install the GD library, otherwise this theme won\'t work properly.';
}
if (!is_writeable(THEME_CACHE_DIR)) {
$warnings[] = 'The cache folder (<b>' . str_replace(WP_CONTENT_DIR, '', THEME_CACHE_DIR) . '</b>) is not writeable. Please set the correct file permissions (<b>\'777\' or \'755\'</b>), otherwise this theme won\'t work properly.';
}
if (!file_exists(THEME_CACHE_DIR . DIRECTORY_SEPARATOR . 'skin.css')) {
$warnings[] = 'The skin style file (<b>' . str_replace(WP_CONTENT_DIR, '', THEME_CACHE_DIR) . '/skin.css' . '</b>) doesn\'t exists or it was deleted. Please manually create this file or click on \'Save changes\' and it will be automatically created.';
}
if (!is_writeable(THEME_CACHE_DIR . DIRECTORY_SEPARATOR . 'skin.css')) {
$warnings[] = 'The skin style file (<b>' . str_replace(WP_CONTENT_DIR, '', THEME_CACHE_DIR) . '/skin.css' . '</b>) is not writeable. Please set the correct permissions (<b>\'777\' or \'755\'</b>), otherwise this theme won\'t work properly.';
}
$str = '';
if (!empty($warnings)) {
$str = '<ul>';
foreach ($warnings as $warning) {
$str .= '<li>' . $warning . '</li>';
}
$str .= '</ul>';
echo "\r\n\t\t\t\t<div id='theme-warning' class='error fade'><p><strong>" . sprintf(__('%1$s Error Messages', 'wt_admin'), THEME_NAME) . "</strong><br/>" . $str . "</p></div>\r\n\t\t\t";
}
}
示例14: execute
/**
* execute function
* @param <type> $request
*/
public function execute($request)
{
$this->setForm(new LocalizationForm());
$languages = $this->getRequest()->getLanguages();
$this->browserLanguage = $languages[0];
if ($request->isMethod('post')) {
$this->form->bind($request->getParameter($this->form->getName()));
if ($this->form->isValid()) {
// For reloading main menu (index.php)
$_SESSION['load.admin.localization'] = true;
$formValues = $this->form->getFormValues();
$defaultLanguage = $formValues['defaultLanguage'];
$setBrowserLanguage = !empty($formValues['setBrowserLanguage']) ? "Yes" : "No";
$supprotedLanguages = $this->form->getLanguages();
if ($setBrowserLanguage == "Yes" && in_array($languages[0], $supprotedLanguages)) {
$defaultLanguage = $languages[0];
}
$this->getUser()->setCulture($defaultLanguage);
$this->getConfigService()->setAdminLocalizationDefaultLanguage($formValues['defaultLanguage']);
$this->getConfigService()->setAdminLocalizationUseBrowserLanguage($setBrowserLanguage);
$this->getUser()->setDateFormat($formValues['defaultDateFormat']);
$this->getConfigService()->setAdminLocalizationDefaultDateFormat($formValues['defaultDateFormat']);
$this->getUser()->setFlash('success', __(TopLevelMessages::SAVE_SUCCESS));
}
$this->redirect("admin/localization");
}
}
示例15: validate
function validate($data = null)
{
$this->errors = array();
if (!empty($data)) {
$data = empty($data[$this->model]) ? $data : $data[$this->model];
foreach ($data as $dkey => $dval) {
$this->data->{$dkey} = stripslashes($dval);
}
extract($data, EXTR_SKIP);
if (empty($gallery_id)) {
$this->errors['title'] = __('No gallery was specified', $this->plugin_name);
}
if (empty($slide_id)) {
$this->errors['title'] = __('No slide was specified', $this->plugin_name);
}
if (empty($this->errors)) {
if ($galleryslide = $this->find(array('gallery_id' => $gallery_id, 'slide_id' => $slide_id))) {
$this->data->id = $galleryslide->id;
}
}
} else {
$this->errors[] = __('No data was posted', $this->plugin_name);
}
return $this->errors;
}