本文整理汇总了PHP中create_slug函数的典型用法代码示例。如果您正苦于以下问题:PHP create_slug函数的具体用法?PHP create_slug怎么用?PHP create_slug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_slug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ppm_scripts
/**
* Register and enqueue scripts and stylesheets
*/
function ppm_scripts()
{
wp_enqueue_style('bootstrap-style', get_template_directory_uri() . '/assets/css/bootstrap.min.css');
wp_enqueue_style('font-awesome', get_template_directory_uri() . '/assets/css/font-awesome.min.css');
wp_enqueue_style('fancybox', get_template_directory_uri() . '/assets/css/jquery.fancybox.css');
wp_enqueue_style('print', get_template_directory_uri() . '/assets/css/print.css', '', '', 'print');
wp_enqueue_style('styles', get_template_directory_uri() . '/assets/css/styles.css');
wp_enqueue_script('bootstrap-script', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array('jquery'), false, true);
wp_enqueue_script('jquery-mask', get_template_directory_uri() . '/assets/js/jquery.mask.min.js', array('jquery'), false, true);
wp_enqueue_script('jquery-fancybox', get_template_directory_uri() . '/assets/js/jquery.fancybox.pack.js', array('jquery'), false, true);
wp_enqueue_script('jquery.cycle2', get_template_directory_uri() . '/assets/js/jquery.cycle2.min.js', array('jquery'), false, true);
wp_enqueue_script('jquery.cycle2.carousel', get_template_directory_uri() . '/assets/js/jquery.cycle2.carousel.min.js', array('jquery'), false, true);
wp_enqueue_script('scripts', get_template_directory_uri() . '/assets/js/scripts.js', array('jquery'), false, true);
$creation_choices = get_field_object('field_5626c03dc0803');
$production_choices = get_field_object('field_5626d2f421b80');
$distribution_choices = get_field_object('field_5626d33421b81');
$clean_choices = [];
foreach ($creation_choices['choices'] as $choice) {
array_push($clean_choices, create_slug($choice));
}
foreach ($production_choices['choices'] as $choice) {
array_push($clean_choices, create_slug($choice));
}
foreach ($distribution_choices['choices'] as $choice) {
array_push($clean_choices, create_slug($choice));
}
$creation_choices = $clean_choices;
$ppm_settings = array('templatePath' => get_bloginfo('template_url'), 'creationChoices' => $creation_choices);
wp_localize_script('scripts', 'ppmSettings', $ppm_settings);
}
示例2: create
/**
* Create a new Profile
*/
public function create()
{
if ($this->input->post()) {
//helpers
$stream = $this->input->post('stream_identifier');
$slug_profile = create_slug($this->input->post('profile_name'));
$fieldlist = $this->get_stream_fields_list($stream);
//we create a Pre helper file and an Post helper file for the new profile.
//In the pre helper, we have a specific function for each field of the stream.
write_file($this->helpers_dir . '/' . strtolower($slug_profile) . '_pre_helper.php', '<?php ' . $this->load->view('templates/pre_process', array('fields' => $fieldlist, 'slug_profile' => $slug_profile), true) . "\n?>");
$stream_obj = $this->streams->stream_obj($stream);
write_file($this->helpers_dir . '/' . strtolower($slug_profile) . '_post_helper.php', '<?php ' . $this->load->view('templates/post_process', array('stream_obj' => $stream_obj, 'slug_profile' => $slug_profile), true) . "\n?>");
}
// Get stream
$stream = $this->streams->stream_obj($this->stream_slug, $this->namespace);
$data->fields = $this->streams_m->get_stream_fields($stream->id);
//we get the list of all the Streams existing in this Pyro Instance
$data->stream_dropdown = $this->get_stream_dropdown_list();
// Processing the POST data
$extra = array('title' => lang($this->namespace . ':title:' . $this->section . ':create'), 'success_message' => lang($this->namespace . ':messages:' . $this->section . ':create:success'), 'failure_message' => lang($this->namespace . ':messages:' . $this->section . ':create:error'), 'return' => 'admin/' . $this->namespace . '/' . $this->section . '/create_profile_step2/-id-');
// Skip these for now, this will be in step 2
$skip = array('xml_path_loop');
$this->streams->cp->entry_form($this->section, $this->namespace, 'new', null, false, $extra, $skip);
// Build the template
$this->template->set('page_title', lang($this->namespace . ':title:' . $this->section . ':create'))->build('admin/profiles/create', $data);
}
示例3: add
public function add()
{
$post = $this->input->post();
if ($post) {
#pr($post);
$this->load->library('form_validation');
$this->form_validation->set_rules('cat_name', 'Category Name', 'trim|required|is_unique[category_master.cat_name]');
$this->form_validation->set_rules('cat_title', 'Category Description', 'trim|required');
if ($_FILES['cat_image']['error'] > 0) {
$this->form_validation->set_rules('cat_image', 'Category Image', 'required');
}
if ($_FILES['cat_image']['error'] == 0) {
$config['overwrite'] = TRUE;
$config['upload_path'] = DOC_ROOT_CATEGORY_IMG;
$config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';
$img_arr = explode('.', $_FILES['cat_image']['name']);
$img_arr = array_reverse($img_arr);
$config['file_name'] = $post['cat_image'] = time() . "_img." . $img_arr[0];
$this->load->library('upload', $config);
if (!$this->upload->do_upload("cat_image")) {
//$error['cat_image'] = $this->upload->display_errors();
$this->form_validation->set_rules('cat_image', 'Category Image', 'required');
}
}
if ($this->form_validation->run() !== false) {
$data = array('cat_name' => $post['cat_name'], 'cat_slug' => create_slug($post['cat_name']), 'cat_title' => $post['cat_title'], 'cat_image' => $post['cat_image'], 'cat_active' => isset($post['cat_active']) ? 1 : 0, 'cat_created_date' => date('Y-m-d H:i:s'), 'cat_modified_date' => date('Y-m-d H:i:s'), 'cat_parent' => 0);
$ret = $this->common_model->insertData(CATEGORY, $data);
if ($ret > 0) {
$ret = $this->common_model->addCategoryOrder($ret);
$flash_arr = array('flash_type' => 'success', 'flash_msg' => 'Category added successfully.');
} else {
$flash_arr = array('flash_type' => 'error', 'flash_msg' => 'An error occurred while processing.');
}
$this->session->set_flashdata($flash_arr);
redirect("admin/category");
}
$data['error_msg'] = validation_errors();
}
$data['view'] = "index";
$data['id'] = '';
$data['categories'] = $this->common_model->getCategoryArray();
$data['action'] = "add";
$data['order'] = json_decode(getSetting("cat_order", true), true);
$this->load->view('admin/content', $data);
}
示例4: validate
/**
* Validate changes to this locotype
* @since Version 3.8.7
* @return true
* @throws \Exception if $this->arrangement is empty
*/
public function validate()
{
if (empty($this->name)) {
throw new Exception("Cannot validate changes to this loco type: name cannot be empty");
return false;
}
if (empty($this->slug)) {
$proposal = create_slug($this->name);
$proposal = substr($proposal, 0, 30);
$query = "SELECT id FROM loco_type WHERE slug = ?";
$result = $this->db->fetchAll($query, $proposal);
if (count($result)) {
$proposal = $proposal . count($result);
}
$this->slug = $proposal;
$this->url = sprintf("%s/type/%s", $this->Module->url, $this->slug);
}
return true;
}
示例5: get_potd
function get_potd()
{
$api_key = get_option('apod_api_key');
$default_status = get_option('apod_default_status');
$post_as = get_option('apod_post_as');
$response = wp_remote_get('https://api.data.gov/nasa/planetary/apod?api_key=' . $api_key . '&format=JSON');
$body = json_decode($response['body']);
if (is_null($post_as) or $post_as == "") {
$user_id = get_user_by('login', $post_as);
} else {
$user_id = '1';
}
if (!is_numeric($user_id)) {
$user_id = '1';
}
$pGUID = 'apod-' . $body->date;
if (getIDfromGUID($pGUID) > 0) {
return;
}
$post_data = array('post_content' => $body->explanation, 'post_title' => $body->title, 'post_name' => create_slug($body->title), 'post_excerpt' => $body->explanation, 'post_status' => $default_status, 'post_author' => $user_id, 'guid' => $pGUID);
$post_id = wp_insert_post($post_data);
//insert the post, return the new post_id
$imgGet = wp_remote_get($body->url);
//grab our image
$imgType = wp_remote_retrieve_header($imgGet, 'content-type');
//get our image type
$imgMirror = wp_upload_bits(rawurldecode(basename($body->url)), '', wp_remote_retrieve_body($imgGet));
//upload image to wordpress
$attachment = array('post_title' => preg_replace('/\\.[^.]+$/', '', basename($body->url)), 'post_mime_type' => $imgType, 'post_content' => '', 'post_status' => 'inherit', 'guid' => basename($body->url), 'post_author' => $user_id, 'post_type' => 'attachment');
require_once ABSPATH . 'wp-admin/includes/image.php';
$attach_id = wp_insert_attachment($attachment, $imgMirror['url'], $post_id);
//insert the attachment and get the ID
$attach_data = wp_generate_attachment_metadata($attach_id, $imgMirror['file']);
//generate the meta-data for the image
wp_update_attachment_metadata($attach_id, $attach_data);
//update the images meta-data
set_post_thumbnail($post_id, $attach_id);
//set the image as featured for the new post
}
示例6: update
public function update($data, $id)
{
$titles = strip_tags($this->clean($data['food_title']));
$ta = array();
$et = explode(" ", $titles);
foreach ($et as $t) {
if ($t != '') {
array_push($ta, $t);
}
}
$ft = join(" ", $ta);
$f = join(" ", $ta);
$arr = array();
$arr['title'] = $ft;
//strip_tags($this->clean($data['title']));
$arr['description'] = $this->clean(htmlentities($data['food_description']));
$arr['recipe'] = strip_tags($data['food_recipe']);
//$this->clean(strip_tags($data['food_recipe']));
$arr['category_ids'] = '';
//$this->clean($cids);
$arr['price_single'] = isset($data['price_single']) && $data['price_single'] != '' ? $this->clean($data['price_single']) : 0.0;
//price single
$arr['price_discounted'] = isset($data['price_discounted']) && $data['price_discounted'] != '' ? $this->clean($data['price_discounted']) : 0.0;
//price discounted
$arr['price_bulk'] = isset($data['price_bulk']) && $data['price_bulk'] != '' ? $this->clean($data['price_bulk']) : 0.0;
//price bulk
$arr['template'] = $this->clean($data['food_template']);
$arr['slug'] = create_slug($f);
$arr['status'] = isset($data['food_status']) ? $this->clean($data['food_status']) : 0;
$sql = $this->updates('food', $arr, 'food_id=' . $this->clean($id));
$query = $this->query($sql);
if ($query) {
return true;
} else {
return false;
}
}
示例7: create_slug
}
} else {
echo "ERROR - Could not retrieve ID from the wp_posts table\n";
die;
}
// Delete current post meta data
$stmt = $conn->prepare($deleteMetadataQuery);
$stmt->bind_param("i", $id);
$stmt->execute();
// Delete current post data
$stmt = $conn->prepare($deletePostQuery);
$stmt->bind_param("i", $id);
$stmt->execute();
// Insert new post data
$stmt = $conn->prepare($insertPostQuery);
$stmt->bind_param("isssssssssssssssisissi", $authorId, $today, $todayGmt, $data[KEY_DESCRIPTION], $data[KEY_TITLE], $empty, $a = "publish", $b = "open", $c = "open", $empty, create_slug($data[KEY_TITLE]), $empty, $empty, $today, $todayGmt, $empty, $zero, $d = "http://www.tabletopdine.com/dev/?post_type=wg_merchant&p=" . $id, $zero, $e = "wg_merchant", $empty, $zero);
$stmt->execute();
// Insert new post data for revision row
$stmt = $conn->prepare($insertPostQuery);
$stmt->bind_param("isssssssssssssssisissi", $authorId, $today, $todayGmt, $empty, $data[KEY_TITLE], $empty, $a = "inherit", $b = "open", $c = "open", $empty, $d = $id . "-revision-v1", $empty, $empty, $today, $todayGmt, $empty, $id, $e = "http://www.tabletopdine.com/dev/" . $id . "-revision-v-1", $zero, $f = "revision", $empty, $zero);
$stmt->execute();
// Insert new post meta data
$stmt = $conn->prepare($insertMetadataQuery);
$stmt->bind_param("isiiisisisisisisisisisisis", $id, $data[KEY_EDIT_LOCK], $id, $data[KEY_EDIT_LAST], $id, $data[KEY_CONTACT_NAME], $id, $data[KEY_CONTACT_TITLE], $id, $data[KEY_CONTACT_STREET], $id, $data[KEY_CONTACT_CITY], $id, $data[KEY_CONTACT_STATE], $id, $data[KEY_CONTACT_POSTAL_CODE], $id, $data[KEY_CONTACT_COUNTRY], $id, $data[KEY_CONTACT_PHONE], $id, $data[KEY_WEBSITE], $id, $data[KEY_FACEBOOK] != null && is_string($data[KEY_FACEBOOK]) && strlen($data[KEY_FACEBOOK]) > 0 ? $data[KEY_FACEBOOK] : $facebook, $id, $data[KEY_TWITTER] != null && is_string($data[KEY_TWITTER]) && strlen($data[KEY_TWITTER]) > 0 ? $data[KEY_TWITTER] : $twitter);
$stmt->execute();
// $stmt = $conn->prepare($thumbnailMetadataQuery);
// $stmt->bind_param("isis",
// $id, $data[KEY_WP_ATTACHED_FILE],
// $id, $data[KEY_WP_ATTACHMENT_METADATA]
// );
// $stmt->execute();
示例8: upload_featured_image_from_url
function upload_featured_image_from_url($post_id, $product_Arr)
{
// Add Featured Image to Post
$image_url = $product_Arr->master_image->url;
// Define the image URL here
$upload_dir = wp_upload_dir();
// Set upload folder
$image_data = file_get_contents($image_url);
// Get image data
$filename = basename($image_url);
// Create image file name
$info = pathinfo($filename);
$ext = $info['extension'];
$name = create_slug($product_Arr->name);
$new_filename = 'square-' . $name . '.' . $ext;
// Check folder permission and define file location
if (wp_mkdir_p($upload_dir['path'])) {
$file = $upload_dir['path'] . '/' . $new_filename;
} else {
$file = $upload_dir['basedir'] . '/' . $new_filename;
}
// Create the image file on the server
file_put_contents($file, $image_data);
// Check image file type
$wp_filetype = wp_check_filetype($filename, null);
// Set attachment data
$attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => sanitize_file_name($filename), 'post_content' => '', 'post_status' => 'inherit');
// Create the attachment
$attach_id = wp_insert_attachment($attachment, $file, $post_id);
// Include image.php
require_once ABSPATH . 'wp-admin/includes/image.php';
// Define attachment metadata
$attach_data = wp_generate_attachment_metadata($attach_id, $file);
// Assign metadata to attachment
wp_update_attachment_metadata($attach_id, $attach_data);
// And finally assign featured image to post
set_post_thumbnail($post_id, $attach_id);
}
示例9: is_string
}
} else {
echo "ERROR - Could not retrieve ID from the wp_posts table\n";
die;
}
// Delete current post meta data
$stmt = $conn->prepare($deleteMetadataQuery);
$stmt->bind_param("i", $id);
$stmt->execute();
// Delete current post data
$stmt = $conn->prepare($deletePostQuery);
$stmt->bind_param("i", $id);
$stmt->execute();
// Insert new post data
$stmt = $conn->prepare($insertPostQuery);
$stmt->bind_param("isssssssssssssssisissi", $authorId, $today, $todayGmt, $data[KEY_DESCRIPTION] != null && is_string($data[KEY_DESCRIPTION]) && strlen($data[KEY_DESCRIPTION]) > 0 ? $data[KEY_DESCRIPTION] : $description, $data[KEY_TITLE], $empty, $a = "publish", $b = "open", $c = "open", $empty, create_slug($data[KEY_TITLE]), $empty, $empty, $today, $todayGmt, $empty, $zero, $d = "http://www.tabletopdine.com/dev/?post_type=wg_merchant&p=" . $id, $zero, $e = "wg_deal", $empty, $zero);
$stmt->execute();
// Insert new post data for revision row
$stmt = $conn->prepare($insertPostQuery);
$stmt->bind_param("isssssssssssssssisissi", $authorId, $today, $todayGmt, $empty, $data[KEY_TITLE], $empty, $a = "inherit", $b = "open", $c = "open", $empty, $d = $id . "-revision-v1", $empty, $empty, $today, $todayGmt, $empty, $id, $e = "http://www.tabletopdine.com/dev/" . $id . "-revision-v-1", $zero, $f = "revision", $empty, $zero);
$stmt->execute();
// Insert Image data for event
$stmt = $conn->prepare($insertPostQuery);
$stmt->bind_param("isssssssssssssssisissi", $authorId, $today, $todayGmt, $hash, $hash, $empty, $a = "inherit", $b = "open", $c = "open", $empty, $hash, $empty, $empty, $today, $todayGmt, $empty, $id, $d = "http://stuffpoint.com/food/image/235785-food-fast-food-combo.png", $zero, $e = "attachment", $f = "image/png", $zero);
$stmt->execute();
// // Insert new post meta data
$stmt = $conn->prepare($insertMetadataQuery);
$stmt->bind_param("isididiiiiiiididisisisisisisiiisiiiiisisisisisisisisisisisisisis", $id, $data[KEY_EXPIRATION_DATE] != null && is_string($data[KEY_EXPIRATION_DATE]) && !empty($data[KEY_EXPIRATION_DATE]) ? $data[KEY_EXPIRATION_DATE] : $expiration, $id, $data[KEY_BASE_PRICE] != null && is_numeric($data[KEY_BASE_PRICE]) && $data[KEY_BASE_PRICE] > 0 ? $data[KEY_BASE_PRICE] : $zero, $id, $data[KEY_DYNAMIC_PRICE] != null && is_numeric($data[KEY_DYNAMIC_PRICE]) && $data[KEY_DYNAMIC_PRICE] > 0 ? $data[KEY_DYNAMIC_PRICE] : $zero, $id, $data[KEY_MIN_PURCHASES] != null && is_numeric($data[KEY_MIN_PURCHASES]) && $data[KEY_MIN_PURCHASES] > 0 ? $data[KEY_MIN_PURCHASES] : $one, $id, $data[KEY_MAX_PURCHASES] != null && is_numeric($data[KEY_MAX_PURCHASES]) && $data[KEY_MAX_PURCHASES] > 0 ? $data[KEY_MAX_PURCHASES] : $hundred, $id, $data[KEY_MAX_PURCHASES_PER_USER] != null && is_numeric($data[KEY_MAX_PURCHASES_PER_USER]) && $data[KEY_MAX_PURCHASES_PER_USER] > 0 ? $data[KEY_MAX_PURCHASES_PER_USER] : $one, $id, $data[KEY_VALUE] != null && is_numeric($data[KEY_VALUE]) && $data[KEY_VALUE] > 0 ? $data[KEY_VALUE] : $zero, $id, $data[KEY_AMOUNT_SAVED] != null && is_numeric($data[KEY_VALUE]) && $data[KEY_AMOUNT_SAVED] > 0 ? $data[KEY_VALUE] : $zero, $id, $data[KEY_HIGHLIGHTS] != null && is_string($data[KEY_HIGHLIGHTS]) && !empty($data[KEY_HIGHLIGHTS]) ? $data[KEY_HIGHLIGHTS] : $highlight, $id, $data[KEY_FINE_PRINT] != null && is_string($data[KEY_FINE_PRINT]) && !empty($data[KEY_FINE_PRINT]) ? $data[KEY_FINE_PRINT] : $finePrint, $id, $data[KEY_VOUCHER_EXPIRATION_DATE] != null && is_string($data[KEY_VOUCHER_EXPIRATION_DATE]) && !empty($data[KEY_VOUCHER_EXPIRATION_DATE]) ? $data[KEY_VOUCHER_EXPIRATION_DATE] : $expiration, $id, $data[KEY_VOUCHER_HOW_TO_USE], $id, $data[KEY_VOUCHER_MAP], $id, $data[KEY_VOUCHER_SERIAL_NUMBER] != null && is_string($data[KEY_VOUCHER_SERIAL_NUMBER]) && !empty($data[KEY_VOUCHER_SERIAL_NUMBER]) ? $data[KEY_VOUCHER_SERIAL_NUMBER] : $hash, $id, $data[KEY_MERCHANT_ID] != null && is_string($data[KEY_MERCHANT_ID]) && !empty($data[KEY_MERCHANT_ID]) ? $data[KEY_MERCHANT_ID] : $merchantId, $id, $data[KEY_VOUCHER_LOCATIONS], $id, $thumbId, $id, $zero, $id, $data[KEY_EDIT_LOCK], $id, $data[KEY_EDIT_LAST], $id, $data[KEY_REDIRECT_URL], $id, $data[KEY_TAXABLE], $id, $taxRate, $id, $data[KEY_SHIPPING], $id, $shippingMode, $id, $shippingDynPrice, $id, $data[KEY_RSS_EXCERPT], $id, $data[KEY_VOUCHER_ID_PREFIX], $id, $data[KEY_VOUCHER_LOGO], $id, $data[KEY_CAPTURE_BEFORE_EXPIRATION], $id, $data[KEY_PREVIEW_PRIVATE_KEY], $id, $data[KEY_FEATURED_CONTENT]);
$stmt->execute();
// $stmt = $conn->prepare($thumbnailQuery);
// $stmt->bind_param("isis",
示例10: get_template_directory_uri
?>
secondary" title="<?php
echo $pos2;
?>
" />
<?php
if ($pos2 == 'Defensa Central') {
?>
<img src="<?php
echo get_template_directory_uri();
?>
/img/pos_secondary.png" alt="<?php
echo $pos2;
?>
" class="<?php
echo create_slug($pos2 . '2');
?>
secondary" title="<?php
echo $pos2;
?>
" />
<?php
}
?>
<?php
}
?>
<div class="player-positions-titles">
示例11: add_category
/**
* Add Category
*
* @param array $data An array of data.
* @uses format_uri
* @return mixed Id on success.
*/
public function add_category($data)
{
if (isset($data['cat_uri']) && $data['cat_uri'] != '') {
$data['cat_uri'] = create_slug($data['cat_uri']);
} else {
$data['cat_uri'] = create_slug($data['cat_name']);
}
if (isset($data['cat_parent']) && $data['cat_parent'] > 0) {
$uri = $this->_get_cat_path($data['cat_parent']);
$data['cat_uri'] = implode('/', $uri) . '/' . $data['cat_uri'];
}
$data['cat_uri'] = $this->_check_uri($data['cat_uri']);
$this->db->insert('categories', $data);
if ($this->db->affected_rows() == 0) {
return FALSE;
}
$cat_id = $this->db->insert_id();
$this->events->trigger('categories_model/add_category', $cat_id);
$this->cache->delete_all('categories_model');
return $cat_id;
}
示例12: base_url
echo $mynl_newsletter[$i]['screenshot'];
?>
" alt=""></a></div>
<?php
} else {
?>
<img style="width:79px;" src="<?php
echo base_url();
?>
assets/img/authornewsletter.png" alt=""></a></div>
<?php
}
?>
<div class="review_detail">
<a class="name" href="<?php
echo site_url('newsletter/specific') . "/" . create_slug($mynl_newsletter[$i]['newsletter_name'], 100) . "/" . $mynl_newsletter[$i]['newsletter_id'];
?>
"><?php
echo $mynl_newsletter[$i]['newsletter_name'];
?>
</a><br/>
<label style="color:#808080; float:left;"><?php
echo _clang(AUTHOR_MK);
?>
</label><span style="float: left; width: 315px;"><?php
echo $mynl_newsletter[$i]['author_name'];
?>
</span>
<?php
$get_rate = $this->newsletter_model->get_rate_by_user($mynl_newsletter[$i]['newsletter_id']);
include "rating/rating_calculation.php";
示例13: createSlug
/**
* Create a URL slug
* @since Version 3.8.7
*/
private function createSlug()
{
$proposal = substr(create_slug($this->title), 0, 60);
$result = $this->db->fetchAll("SELECT id FROM event WHERE slug = ?", $proposal);
if (count($result)) {
$proposal .= count($result);
}
$this->slug = $proposal;
$this->commit();
}
示例14: array
include_once ABSPATH . WPINC . '/feed.php';
$termstring = $s;
$dilarang = array("+-amazon");
$rss = fetch_feed('http://www.bing.com/search?q=' . urlencode($termstring) . '+"php"&go=&form=QBLH&filt=all&format=rss');
if (!is_wp_error($rss)) {
// Checks that the object is created correctly
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
}
if ($maxitems == 0) {
echo '';
} else {
// Loop through each feed item and display each item as a hyperlink.
foreach ($rss_items as $item) {
$title = '' . htmlspecialchars(BannedKeyword(hilangkan_karakter($item->get_title()))) . '';
$title_arr = explode(" ", $title);
$first_word = $title_arr[0];
$post_slug = create_slug($title);
$permalinks = get_bloginfo("url") . "/" . strtolower($first_word) . "/" . $post_slug . ".pdf";
echo htmlspecialchars(BannedKeyword(hilangkan_karakter($item->get_title())));
?>
<?php
echo strtolower(htmlspecialchars(BannedKeyword(hilangkan_karakter($item->get_content()))));
?>
.
<?php
}
}
?>
</p>
</div>
示例15: createSlug
/**
* Generate the URL slug
* @since Version 3.7.5
* @param int $id
* @param string $name
* @return string
*/
public function createSlug($id = false, $name = false)
{
if (RP_DEBUG) {
global $site_debug;
$debug_timer_start = microtime(true);
}
// Assume ZendDB
$find = array("(", ")", "-");
$replace = array();
foreach ($find as $item) {
$replace[] = "";
}
if (filter_var($id, FILTER_VALIDATE_INT) && !$name) {
$name = $this->db->fetchOne("SELECT organisation_name FROM organisation WHERE organisation_id = ?", $id);
} elseif (filter_var($id, FILTER_VALIDATE_INT) && is_string($name)) {
// Do nothing
} elseif (isset($this->name) && !empty($this->name)) {
$name = $this->name;
$id = $this->id;
} else {
return false;
}
$name = str_replace($find, $replace, $name);
$proposal = create_slug($name);
/**
* Trim it if the slug is too long
*/
if (strlen($proposal) >= 256) {
$proposal = substr($poposal, 0, 200);
}
/**
* Check that we haven't used this slug already
*/
$result = $this->db->fetchAll("SELECT organisation_id FROM organisation WHERE organisation_slug = ? AND organisation_id != ?", array($proposal, $id));
if (count($result)) {
$proposal .= count($result);
}
if (isset($this->slug)) {
$this->slug = $proposal;
}
/**
* Add this slug to the database
*/
$data = array("organisation_slug" => $proposal);
$where = array("organisation_id = ?" => $id);
$rs = $this->db->update("organisation", $data, $where);
if (RP_DEBUG) {
if ($rs === false) {
$site_debug[] = "Zend_DB: FAILED create url slug for organisation ID " . $id . " in " . round(microtime(true) - $debug_timer_start, 5) . "s";
} else {
$site_debug[] = "Zend_DB: SUCCESS create url slug for organisation ID " . $id . " in " . round(microtime(true) - $debug_timer_start, 5) . "s";
}
}
/**
* Return it
*/
return $proposal;
}