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


PHP add_meta函数代码示例

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


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

示例1: paint

 public function paint($page, $data = NULL)
 {
     $this->data['css'] = add_css($this->css);
     $this->data['meta'] = add_meta($this->meta);
     $this->data['js'] = add_js($this->js);
     $this->data['title'] = $this->title;
     $this->data['body_class'] = $this->CI->router->fetch_class();
     if (!is_null($data)) {
         foreach ($data as $key => $value) {
             $this->data[$key] = $value;
         }
     }
     foreach ($this->slice as $key => $value) {
         if (is_array($value)) {
             foreach ($value as $k => $v) {
                 if (method_exists($this->CI->slices, $v)) {
                     $result = call_user_func_array(array($this->CI->slices, $v), array());
                     foreach ($result as $restult_k => $result_v) {
                         if (!isset($this->data[$restult_k])) {
                             $this->data[$restult_k] = $result_v;
                         }
                     }
                 }
                 $this->data[$k] = $this->CI->load->view('slices/' . $v, $this->data, TRUE) . "\n";
             }
         } elseif (!is_numeric($key)) {
             if (method_exists($this->CI->slices, $key)) {
                 $result = call_user_func_array(array($this->CI->slices, $key), array());
                 foreach ($result as $k => $v) {
                     if (!isset($this->data[$k])) {
                         $this->data[$k] = $v;
                     }
                 }
             }
             $this->data[$key] = $this->CI->load->view('slices/' . $value, $this->data, TRUE) . "\n";
         } else {
             if (method_exists($this->CI->slices, $value)) {
                 $result = call_user_func_array(array($this->CI->slices, $value), array());
                 foreach ($result as $restult_k => $result_v) {
                     if (!isset($this->data[$restult_k])) {
                         $this->data[$restult_k] = $result_v;
                     }
                 }
             }
             $this->data[$value] = $this->CI->load->view('slices/' . $value, $this->data, TRUE) . "\n";
         }
     }
     $this->data['content'] = $this->CI->load->view('pages/' . $page, $this->data, TRUE) . "\n";
     $this->CI->load->view('layouts/' . $this->layout, $this->data);
 }
开发者ID:barayuda,项目名称:k-starter,代码行数:50,代码来源:Stencil.php

示例2: paint

 public function paint($page, $data = NULL)
 {
     $this->data['css'] = add_css($this->css);
     $this->data['meta'] = add_meta($this->meta);
     $this->data['js'] = add_js($this->js);
     $this->data['title'] = $this->title;
     if (!is_null($data)) {
         foreach ($data as $key => $value) {
             $this->data[$key] = $value;
         }
     }
     foreach ($this->slice as $slice) {
         $this->data[$slice] = $this->CI->load->view('slices/' . $slice, $this->data, TRUE) . "\n";
     }
     $this->data['content'] = $this->CI->load->view('pages/' . $page, $this->data, TRUE) . "\n";
     $this->CI->load->view('layouts/' . $this->layout, $this->data);
 }
开发者ID:wisutsak,项目名称:ElectionDesk,代码行数:17,代码来源:Stencil.php

示例3: edit_post

function edit_post()
{
    global $user_ID;
    $post_ID = (int) $_POST['post_ID'];
    if (!current_user_can('edit_post', $post_ID)) {
        die(__('You are not allowed to edit this post.'));
    }
    // Rename.
    $_POST['ID'] = (int) $_POST['post_ID'];
    $_POST['post_content'] = $_POST['content'];
    $_POST['post_excerpt'] = $_POST['excerpt'];
    $_POST['post_parent'] = $_POST['parent_id'];
    $_POST['to_ping'] = $_POST['trackback_url'];
    if (!empty($_POST['post_author_override'])) {
        $_POST['post_author'] = (int) $_POST['post_author_override'];
    } else {
        if (!empty($_POST['post_author'])) {
            $_POST['post_author'] = (int) $_POST['post_author'];
        } else {
            $_POST['post_author'] = (int) $_POST['user_ID'];
        }
    }
    if ($_POST['post_author'] != $_POST['user_ID'] && !current_user_can('edit_others_posts')) {
        die(__('You cannot post as this user.'));
    }
    // What to do based on which button they pressed
    if ('' != $_POST['saveasdraft']) {
        $_POST['post_status'] = 'draft';
    }
    if ('' != $_POST['saveasprivate']) {
        $_POST['post_status'] = 'private';
    }
    if ('' != $_POST['publish']) {
        $_POST['post_status'] = 'publish';
    }
    if ('' != $_POST['advanced']) {
        $_POST['post_status'] = 'draft';
    }
    if ('' != $_POST['savepage']) {
        $_POST['post_status'] = 'static';
    }
    if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts')) {
        $_POST['post_status'] = 'draft';
    }
    if ('static' == $_POST['post_status'] && !current_user_can('edit_pages')) {
        die(__('This user cannot edit pages.'));
    }
    if (!isset($_POST['comment_status'])) {
        $_POST['comment_status'] = 'closed';
    }
    if (!isset($_POST['ping_status'])) {
        $_POST['ping_status'] = 'closed';
    }
    if (!empty($_POST['edit_date'])) {
        $aa = $_POST['aa'];
        $mm = $_POST['mm'];
        $jj = $_POST['jj'];
        $hh = $_POST['hh'];
        $mn = $_POST['mn'];
        $ss = $_POST['ss'];
        $jj = $jj > 31 ? 31 : $jj;
        $hh = $hh > 23 ? $hh - 24 : $hh;
        $mn = $mn > 59 ? $mn - 60 : $mn;
        $ss = $ss > 59 ? $ss - 60 : $ss;
        $_POST['post_date'] = "{$aa}-{$mm}-{$jj} {$hh}:{$mn}:{$ss}";
        $_POST['post_date_gmt'] = get_gmt_from_date("{$aa}-{$mm}-{$jj} {$hh}:{$mn}:{$ss}");
    }
    // Meta Stuff
    if ($_POST['meta']) {
        foreach ($_POST['meta'] as $key => $value) {
            update_meta($key, $value['key'], $value['value']);
        }
    }
    if ($_POST['deletemeta']) {
        foreach ($_POST['deletemeta'] as $key => $value) {
            delete_meta($key);
        }
    }
    add_meta($post_ID);
    wp_update_post($_POST);
    // Now that we have an ID we can fix any attachment anchor hrefs
    fix_attachment_links($post_ID);
    return $post_ID;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:84,代码来源:admin-functions.php

示例4: wp_write_post

/**
 * Creates a new post from the "Write Post" form using $_POST information.
 *
 * @since unknown
 *
 * @return unknown
 */
function wp_write_post()
{
    global $user_ID;
    if ('page' == $_POST['post_type']) {
        if (!current_user_can('edit_pages')) {
            return new WP_Error('edit_pages', __('You are not allowed to create pages on this blog.'));
        }
    } else {
        if (!current_user_can('edit_posts')) {
            return new WP_Error('edit_posts', __('You are not allowed to create posts or drafts on this blog.'));
        }
    }
    // Check for autosave collisions
    $temp_id = false;
    if (isset($_POST['temp_ID'])) {
        $temp_id = (int) $_POST['temp_ID'];
        if (!($draft_ids = get_user_option('autosave_draft_ids'))) {
            $draft_ids = array();
        }
        foreach ($draft_ids as $temp => $real) {
            if (time() + $temp > 86400) {
                // 1 day: $temp is equal to -1 * time( then )
                unset($draft_ids[$temp]);
            }
        }
        if (isset($draft_ids[$temp_id])) {
            // Edit, don't write
            $_POST['post_ID'] = $draft_ids[$temp_id];
            unset($_POST['temp_ID']);
            update_user_option($user_ID, 'autosave_draft_ids', $draft_ids);
            return edit_post();
        }
    }
    $translated = _wp_translate_postdata(false);
    if (is_wp_error($translated)) {
        return $translated;
    }
    if (isset($_POST['visibility'])) {
        switch ($_POST['visibility']) {
            case 'public':
                $_POST['post_password'] = '';
                break;
            case 'password':
                unset($_POST['sticky']);
                break;
            case 'private':
                $_POST['post_status'] = 'private';
                $_POST['post_password'] = '';
                unset($_POST['sticky']);
                break;
        }
    }
    // Create the post.
    $post_ID = wp_insert_post($_POST);
    if (is_wp_error($post_ID)) {
        return $post_ID;
    }
    if (empty($post_ID)) {
        return 0;
    }
    add_meta($post_ID);
    // Reunite any orphaned attachments with their parent
    if (!($draft_ids = get_user_option('autosave_draft_ids'))) {
        $draft_ids = array();
    }
    if ($draft_temp_id = (int) array_search($post_ID, $draft_ids)) {
        _relocate_children($draft_temp_id, $post_ID);
    }
    if ($temp_id && $temp_id != $draft_temp_id) {
        _relocate_children($temp_id, $post_ID);
    }
    // Update autosave collision detection
    if ($temp_id) {
        $draft_ids[$temp_id] = $post_ID;
        update_user_option($user_ID, 'autosave_draft_ids', $draft_ids);
    }
    // Now that we have an ID we can fix any attachment anchor hrefs
    _fix_attachment_links($post_ID);
    wp_set_post_lock($post_ID, $GLOBALS['current_user']->ID);
    return $post_ID;
}
开发者ID:schr,项目名称:wordpress,代码行数:88,代码来源:post.php

示例5: edit_post


//.........这里部分代码省略.........
		$now = time();
		$then = strtotime($post->post_date_gmt . ' +0000');
		// Keep autosave_interval in sync with autosave-js.php.
		$delta = apply_filters( 'autosave_interval', 120 ) / 2;
		if ( ($now - $then) < $delta )
			return $post_ID;
	}

	// Rename.
	$_POST['ID'] = (int) $_POST['post_ID'];
	$_POST['post_content'] = $_POST['content'];
	$_POST['post_excerpt'] = $_POST['excerpt'];
	$_POST['post_parent'] = $_POST['parent_id'];
	$_POST['to_ping'] = $_POST['trackback_url'];

	if (!empty ( $_POST['post_author_override'] ) ) {
		$_POST['post_author'] = (int) $_POST['post_author_override'];
	} else
		if (!empty ( $_POST['post_author'] ) ) {
			$_POST['post_author'] = (int) $_POST['post_author'];
		} else {
			$_POST['post_author'] = (int) $_POST['user_ID'];
		}

	if ( $_POST['post_author'] != $_POST['user_ID'] ) {
		if ( 'page' == $_POST['post_type'] ) {
			if ( !current_user_can( 'edit_others_pages' ) )
				wp_die( __('You are not allowed to edit pages as this user.' ));
		} else {
			if ( !current_user_can( 'edit_others_posts' ) )
				wp_die( __('You are not allowed to edit posts as this user.' ));

		}
	}

	// What to do based on which button they pressed
	if ('' != $_POST['saveasdraft'] )
		$_POST['post_status'] = 'draft';
	if ('' != $_POST['saveasprivate'] )
		$_POST['post_status'] = 'private';
	if ('' != $_POST['publish'] )
		$_POST['post_status'] = 'publish';
	if ('' != $_POST['advanced'] )
		$_POST['post_status'] = 'draft';

	if ( 'page' == $_POST['post_type'] ) {
		if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_pages' ))
			$_POST['post_status'] = 'draft';
	} else {
		if ('publish' == $_POST['post_status'] && !current_user_can( 'edit_published_posts' ))
			$_POST['post_status'] = 'draft';
	}

	if (!isset( $_POST['comment_status'] ))
		$_POST['comment_status'] = 'closed';

	if (!isset( $_POST['ping_status'] ))
		$_POST['ping_status'] = 'closed';

	if (!empty ( $_POST['edit_date'] ) ) {
		$aa = $_POST['aa'];
		$mm = $_POST['mm'];
		$jj = $_POST['jj'];
		$hh = $_POST['hh'];
		$mn = $_POST['mn'];
		$ss = $_POST['ss'];
		$jj = ($jj > 31 ) ? 31 : $jj;
		$hh = ($hh > 23 ) ? $hh -24 : $hh;
		$mn = ($mn > 59 ) ? $mn -60 : $mn;
		$ss = ($ss > 59 ) ? $ss -60 : $ss;
		$_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
		$_POST['post_date_gmt'] = get_gmt_from_date( "$aa-$mm-$jj $hh:$mn:$ss" );
	}

	// Meta Stuff
	if ( $_POST['meta'] ) {
		foreach ( $_POST['meta'] as $key => $value )
			update_meta( $key, $value['key'], $value['value'] );
	}

	if ( $_POST['deletemeta'] ) {
		foreach ( $_POST['deletemeta'] as $key => $value )
			delete_meta( $key );
	}

	add_meta( $post_ID );

	wp_update_post( $_POST );

	// Reunite any orphaned attachments with their parent
	if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
		$draft_ids = array();
	if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
		relocate_children( $draft_temp_id, $post_ID );

	// Now that we have an ID we can fix any attachment anchor hrefs
	fix_attachment_links( $post_ID );

	return $post_ID;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:admin-functions.php

示例6: current_time

     }
     if ($pid < 0) {
         $now = current_time('timestamp', 1);
         if ($pid = wp_insert_post(array('post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now))))) {
             if (is_wp_error($pid)) {
                 $x = new WP_Ajax_Response(array('what' => 'meta', 'data' => $pid));
                 $x->send();
             }
             if (!($mid = add_meta($pid))) {
                 die(__('Please provide a custom field value.'));
             }
         } else {
             die('0');
         }
     } else {
         if (!($mid = add_meta($pid))) {
             die(__('Please provide a custom field value.'));
         }
     }
     $meta = get_post_meta_by_id($mid);
     $pid = (int) $meta->post_id;
     $meta = get_object_vars($meta);
     $x = new WP_Ajax_Response(array('what' => 'meta', 'id' => $mid, 'data' => _list_meta_row($meta, $c), 'position' => 1, 'supplemental' => array('postid' => $pid)));
 } else {
     $mid = (int) array_pop(array_keys($_POST['meta']));
     $key = $_POST['meta'][$mid]['key'];
     $value = $_POST['meta'][$mid]['value'];
     if (!($meta = get_post_meta_by_id($mid))) {
         die('0');
     }
     // if meta doesn't exist
开发者ID:nagyist,项目名称:laura-wordpress,代码行数:31,代码来源:admin-ajax.php

示例7: do_action

         }
         do_action('publish_post', $post_ID);
         do_trackback($postObject, $useutf8);
     }
     // Meta Stuff
     if ($meta) {
         foreach ($meta as $key => $value) {
             update_meta($key, $value['key'], $value['value']);
         }
     }
     if ($deletemeta) {
         foreach ($deletemeta as $key => $value) {
             delete_meta($key);
         }
     }
     add_meta($post_ID);
     do_action('edit_post', $post_ID);
     exit;
     break;
     //Show Delete Cofirmation Screen
 //Show Delete Cofirmation Screen
 case 'confirmdelete':
     //Check User_Level
     user_level_check();
     //Rendering Admin Screen header
     $parent_file = 'edit.php';
     $title = 'Delete Post';
     $standalone = 0;
     require_once 'admin-header.php';
     //Check Paramaters
     init_param('GET', 'post', 'integer', NO_DEFAULT_PARAM, true);
开发者ID:BackupTheBerlios,项目名称:nobunobuxoops-svn,代码行数:31,代码来源:post.php

示例8: set_custom_fields

 /**
  * Set custom fields for post.
  *
  * @since 2.5.0
  *
  * @param int $post_id Post ID.
  * @param array $fields Custom fields.
  */
 function set_custom_fields($post_id, $fields)
 {
     $post_id = (int) $post_id;
     foreach ((array) $fields as $meta) {
         if (isset($meta['id'])) {
             $meta['id'] = (int) $meta['id'];
             if (isset($meta['key'])) {
                 update_meta($meta['id'], $meta['key'], $meta['value']);
             } else {
                 delete_meta($meta['id']);
             }
         } else {
             $_POST['metakeyinput'] = $meta['key'];
             $_POST['metavalue'] = $meta['value'];
             add_meta($post_id);
         }
     }
 }
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:26,代码来源:xmlrpc.php

示例9: logthis

    }
    if (get_array_value(CMS::$cache[$module_name]['config'], 'disabled' === true)) {
        continue;
    }
    logthis('applying template processor at module: ' . $module_name);
    $template = CMS::$cache[$module_name]['object']->ContentGenerator($template);
    logthis('template processor finished at module: ' . $module_name);
    if (get_array_value(CMS::$cache[$module_name]['config'], 'break_after', false)) {
        break;
    }
}
// remove unused templates
$template = preg_replace('~</?macro.*?>~', '', $template);
$template = preg_replace('~\\[/?macro.*?\\]~', '', $template);
// back-replace protected templates
$template = str_replace('<protected-macro', '<macro', $template);
$template = str_replace('[protected-macro', '[macro', $template);
$template = str_replace('</protected-macro', '</macro', $template);
$template = str_replace('[/protected-macro', '[/macro', $template);
logthis('unused templates removed');
$template = popup_messages_to_template($template);
logthis('popups added');
// flush CSS and JS storages
$template = flush_CSS($template);
$template = flush_JS($template);
// sign it!
$template = add_meta($template, 'name', 'generator', 'JuliaCMS Valenok Edition');
// yeah we did it!
logthis('completed, adding log results and flushing!');
echo $template;
terminate();
开发者ID:kzotoff,项目名称:JuliaCMS,代码行数:31,代码来源:index.php

示例10: wp_write_post


//.........这里部分代码省略.........

	if (!empty ( $_POST['post_author_override'] ) ) {
		$_POST['post_author'] = (int) $_POST['post_author_override'];
	} else {
		if (!empty ( $_POST['post_author'] ) ) {
			$_POST['post_author'] = (int) $_POST['post_author'];
		} else {
			$_POST['post_author'] = (int) $_POST['user_ID'];
		}

	}

	if ( $_POST['post_author'] != $_POST['user_ID'] ) {
		if ( 'page' == $_POST['post_type'] ) {
			if ( !current_user_can( 'edit_others_pages' ) )
				return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) );
		} else {
			if ( !current_user_can( 'edit_others_posts' ) )
				return new WP_Error( 'edit_others_posts', __( 'You are not allowed to post as this user.' ) );

		}
	}

	// What to do based on which button they pressed
	if ( isset($_POST['saveasdraft']) && '' != $_POST['saveasdraft'] )
		$_POST['post_status'] = 'draft';
	if ( isset($_POST['saveasprivate']) && '' != $_POST['saveasprivate'] )
		$_POST['post_status'] = 'private';
	if ( isset($_POST['publish']) && ( '' != $_POST['publish'] ) && ( $_POST['post_status'] != 'private' ) )
		$_POST['post_status'] = 'publish';
	if ( isset($_POST['advanced']) && '' != $_POST['advanced'] )
		$_POST['post_status'] = 'draft';

	if ( 'page' == $_POST['post_type'] ) {
		if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_pages' ) )
			$_POST['post_status'] = 'pending';
	} else {
		if ('publish' == $_POST['post_status'] && !current_user_can( 'publish_posts' ) )
			$_POST['post_status'] = 'pending';
	}

	if (!isset( $_POST['comment_status'] ))
		$_POST['comment_status'] = 'closed';

	if (!isset( $_POST['ping_status'] ))
		$_POST['ping_status'] = 'closed';

	foreach ( array ('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
		if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
			$_POST['edit_date'] = '1';
			break;
		}
	}

	if (!empty ( $_POST['edit_date'] ) ) {
		$aa = $_POST['aa'];
		$mm = $_POST['mm'];
		$jj = $_POST['jj'];
		$hh = $_POST['hh'];
		$mn = $_POST['mn'];
		$ss = $_POST['ss'];
		$jj = ($jj > 31 ) ? 31 : $jj;
		$hh = ($hh > 23 ) ? $hh -24 : $hh;
		$mn = ($mn > 59 ) ? $mn -60 : $mn;
		$ss = ($ss > 59 ) ? $ss -60 : $ss;
		$_POST['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss );
		$_POST['post_date_gmt'] = get_gmt_from_date( $_POST['post_date'] );
	}

	// Create the post.
	$post_ID = wp_insert_post( $_POST );
	if ( is_wp_error( $post_ID ) )
		return $post_ID;

	if ( empty($post_ID) )
		return 0;

	add_meta( $post_ID );

	// Reunite any orphaned attachments with their parent
	if ( !$draft_ids = get_user_option( 'autosave_draft_ids' ) )
		$draft_ids = array();
	if ( $draft_temp_id = (int) array_search( $post_ID, $draft_ids ) )
		_relocate_children( $draft_temp_id, $post_ID );
	if ( $temp_id && $temp_id != $draft_temp_id )
		_relocate_children( $temp_id, $post_ID );

	// Update autosave collision detection
	if ( $temp_id ) {
		$draft_ids[$temp_id] = $post_ID;
		update_user_option( $user_ID, 'autosave_draft_ids', $draft_ids );
	}

	// Now that we have an ID we can fix any attachment anchor hrefs
	_fix_attachment_links( $post_ID );

	wp_set_post_lock( $post_ID, $GLOBALS['current_user']->ID );

	return $post_ID;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:post.php

示例11: print_metas

    } else {
        return false;
    }
}
function print_metas()
{
    global $yg_metas;
    foreach ($yg_metas as $metakey => $metacontent) {
        $metakey = preg_replace('|[^A-Za-z0-9-]+|', '', $metakey);
        $metatype = $metacontent[1] === true ? 'http-equiv' : 'name';
        $metacontent = htmlspecialchars($metacontent[0]);
        echo '<meta ' . $metatype . '="' . $metakey . '" content="' . $metacontent . '">' . "\n";
    }
}
add_action('yg_meta', 'print_metas');
add_meta('generator', 'Yogo ' . YG_VERSION_FULL);
function get_header()
{
    $template = get_query_template('header');
    if (!empty($template)) {
        load_template($template, true);
    } else {
        Core::log('Header file missing for theme', YG_WARNING);
    }
}
function get_footer()
{
    $template = get_query_template('footer');
    if (!empty($template)) {
        load_template($template, true);
    } else {
开发者ID:vinerz,项目名称:yogo,代码行数:31,代码来源:templatemanager.php

示例12: header

                    $proceed = TRUE;
                }
            }
        }
    }
}
if (!$validpage) {
    header("Location: 404");
} else {
    if ($proceed) {
        ob_start();
        $pagetitle = ucfirst($page);
        if ($page == "404") {
            $pagetitle = "HTTP Error " . $page;
        }
        add_meta($pagetitle);
        ?>
			<div id="header">
				<a id="logo" href="<?php 
        if ($_SESSION['loginuserid'] == "") {
            print "login";
        } else {
            if ($user_details->admin == 1) {
                print "admin";
            } else {
                if (isset($user_bookings)) {
                    print "checkout";
                } else {
                    print "browse";
                }
            }
开发者ID:myjavawork,项目名称:actisoft_activitiesweeksystem,代码行数:31,代码来源:index.php

示例13: contentGenerator

 function contentGenerator($template)
 {
     $USERFILES_DIRS = CMS::$R['USERFILES_DIRS'];
     // если этот флажок есть, будет вызван редактор вместо отображения контента
     $edit_mode = isset($_GET['edit']);
     // идентификатор странички, которую надо вставить в шаблон. валидация не нужна - делается поиск в массиве
     // собираем список имеющихся страниц
     $pages = array();
     $query = CMS::$DB->query("select * from `{$this->CONFIG['table']}`");
     while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
         $pages[$row['alias']] = $row;
     }
     $page_id = isset($_GET['p_id']) ? $_GET['p_id'] : DEFAULT_PAGE_ALIAS;
     // ок, берем стандартную страницу, если таковая есть
     $page_found = false;
     if (isset($pages[$page_id])) {
         $page_found = true;
         $page_info = $pages[$page_id];
     } else {
         // если нужного идентификатора нет в страницах, посмотрим в меню, если там найдется - пускай сами разбираются
         if (module_get_config('menu', $menu_module_config) === true) {
             $query = CMS::$DB->query("select alias from `{$menu_module_config['config']['table_menu']}` where alias > ''");
             while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
                 if ($page_id == $row['alias']) {
                     $page_found = true;
                     return $template;
                 }
             }
         }
     }
     // если страница не найдена, попробуем использовать то, что указано в настройках для страницы 404,
     // если и там нету - тупо заменяем макрос на строку и вываливаемся
     if (!$page_found) {
         header('HTTP/1.1 404 Not found');
         if (isset($pages[$this->CONFIG['page_404']])) {
             $page_info = $pages[$this->CONFIG['page_404']];
         } else {
             $template = preg_replace(macro_regexp('content'), 'Страница не найдена', $template);
             return $template;
         }
     }
     // имя файла с контентом
     $content_filename = isset($page_info['filename']) && file_exists($USERFILES_DIRS['pages']['dir'] . $page_info['filename']) ? $USERFILES_DIRS['pages']['dir'] . $page_info['filename'] : $this->CONFIG['page_404'];
     // в режиме редактирования текст/xml не генерируем, а показываем в редакторе (textarea)
     if ($edit_mode && user_allowed_to('edit pages')) {
         switch (pathinfo($page_info['filename'], PATHINFO_EXTENSION)) {
             case 'php':
             case 'xml':
                 $pagehtml = sprintf(MODULE_CONTENT_TEXTAREA_WRAPPER_PHP, $page_id, @file_get_contents($content_filename));
                 break;
             default:
                 $pagecontent = @file_get_contents($content_filename);
                 // при редактировании заменим макросы на защищенную версию, иначе следующие модули на них среагируют
                 // и заменят на свой контент, что наи не нужно. ядро само заменит их обратно потом
                 $pagecontent = str_replace('<macro', '<protected-macro', $pagecontent);
                 $pagecontent = str_replace('[macro', '[protected-macro', $pagecontent);
                 $pagecontent = str_replace('</macro', '</protected-macro', $pagecontent);
                 $pagecontent = str_replace('[/macro', '[/protected-macro', $pagecontent);
                 $pagehtml = sprintf(MODULE_CONTENT_TEXTAREA_WRAPPER, $page_id, $pagecontent);
                 break;
         }
     } else {
         // если html, тащим как есть, иначе формируем с помошью генератора или XSLT
         switch ($ext = pathinfo($content_filename, PATHINFO_EXTENSION)) {
             case 'php':
                 include_once $content_filename;
                 $pagehtml = call_user_func($page_info['generator']);
                 break;
             case 'xml':
                 $pagehtml = XSLTransform($content_filename, $USERFILES_DIRS['xsl']['dir'] . $page_info['xsl'], false, false);
                 break;
             default:
                 ($pagehtml = file_get_contents($content_filename)) !== false or $pagehtml = 'error reading page content (code CONTENT/001)';
                 break;
         }
     }
     // если есть BODY, берем его внутреннее содержимое, иначе весь файл целиком
     if (preg_match(self::REGEXP_HTML_BODY, $pagehtml, $page_body) > 0) {
         $replace = $page_body[1];
     } else {
         $replace = $pagehtml;
     }
     if (isset($_GET['print'])) {
         $template = str_replace('%content%', $replace, MODULE_CONTENT_PRINT_FORM);
     } else {
         $template = preg_replace(macro_regexp('content'), $replace, $template);
     }
     // мета в заголовке. если только буквы-цифры, делаем мету keywords
     if (preg_match('~^[a-zA-Zа-яА-Я0-9,.\\-\\s]+$~ui', $page_info['meta'], $match)) {
         $template = add_meta($template, 'name', 'keywords', $match[0]);
     } elseif (preg_match_all('~(\\(([a-zA-Z\\-]*)\\|([a-zA-Z\\-0-9]+)\\|([a-zA-Z\\-0-9а-яА-Я.,;:\\s+=!@#$%^&*\\(\\)]*)\\))~smui', $page_info['meta'], $matches)) {
         // не прокатило, попробуем структуру со скобками и пайпами
         for ($i = 0; $i < count($matches[0]); $i++) {
             $template = add_meta($template, $matches[2][$i], $matches[3][$i], $matches[4][$i]);
         }
     } elseif (preg_match_all('~<meta\\s[^>]+>~smui', $page_info['meta'], $matches)) {
         // проверим, возможно вписали сырые теги
         for ($i = 0; $i < count($matches[0]); $i++) {
             $template = str_insert_before('</head>', $matches[0][$i] . PHP_EOL, $template);
         }
//.........这里部分代码省略.........
开发者ID:kzotoff,项目名称:JuliaCMS,代码行数:101,代码来源:func.php

示例14: wp_write_post

/**
 * Creates a new post from the "Write Post" form using $_POST information.
 *
 * @since 2.1.0
 *
 * @global WP_User $current_user
 *
 * @return int|WP_Error
 */
function wp_write_post()
{
    if (isset($_POST['post_type'])) {
        $ptype = get_post_type_object($_POST['post_type']);
    } else {
        $ptype = get_post_type_object('post');
    }
    if (!current_user_can($ptype->cap->edit_posts)) {
        if ('page' == $ptype->name) {
            return new WP_Error('edit_pages', __('Sorry, you are not allowed to create pages on this site.'));
        } else {
            return new WP_Error('edit_posts', __('Sorry, you are not allowed to create posts or drafts on this site.'));
        }
    }
    $_POST['post_mime_type'] = '';
    // Clear out any data in internal vars.
    unset($_POST['filter']);
    // Edit don't write if we have a post id.
    if (isset($_POST['post_ID'])) {
        return edit_post();
    }
    if (isset($_POST['visibility'])) {
        switch ($_POST['visibility']) {
            case 'public':
                $_POST['post_password'] = '';
                break;
            case 'password':
                unset($_POST['sticky']);
                break;
            case 'private':
                $_POST['post_status'] = 'private';
                $_POST['post_password'] = '';
                unset($_POST['sticky']);
                break;
        }
    }
    $translated = _wp_translate_postdata(false);
    if (is_wp_error($translated)) {
        return $translated;
    }
    // Create the post.
    $post_ID = wp_insert_post($_POST);
    if (is_wp_error($post_ID)) {
        return $post_ID;
    }
    if (empty($post_ID)) {
        return 0;
    }
    add_meta($post_ID);
    add_post_meta($post_ID, '_edit_last', $GLOBALS['current_user']->ID);
    // Now that we have an ID we can fix any attachment anchor hrefs
    _fix_attachment_links($post_ID);
    wp_set_post_lock($post_ID);
    return $post_ID;
}
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:64,代码来源:post.php

示例15: current_time

		) );
	}
	$x->send();
	break;
case 'add-meta' :
	if ( !current_user_can( 'edit_post', $id ) )
		die('-1');
	if ( $id < 0 ) {
		$now = current_time('timestamp', 1);
		if ( $pid = wp_insert_post( array(
			'post_title' => sprintf('Draft created on %s at %s', date(get_option('date_format'), $now), date(get_option('time_format'), $now))
		) ) )
			$mid = add_meta( $pid );
		else
			die('0');
	} else if ( !$mid = add_meta( $id ) ) {
		die('0');
	}

	$meta = get_post_meta_by_id( $mid );
	$key = $meta->meta_key;
	$value = $meta->meta_value;
	$pid = (int) $meta->post_id;

	$x = new WP_Ajax_Response( array(
		'what' => 'meta',
		'id' => $mid,
		'data' => wp_ajax_meta_row( $pid, $mid, $key, $value ),
		'supplemental' => array('postid' => $pid)
	) );
	$x->send();
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:31,代码来源:admin-ajax.php


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