本文整理汇总了PHP中add_category函数的典型用法代码示例。如果您正苦于以下问题:PHP add_category函数的具体用法?PHP add_category怎么用?PHP add_category使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_category函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetupMulticomicPartialPaths
function testSetupMulticomicPartialPaths()
{
$cp = $this->getMock('ComicPress', array('_is_dir'));
wp_set_post_categories(1, array('2', '3'));
add_category('2', (object) array('slug' => 'test-one'));
add_category('3', (object) array('slug' => 'test-two'));
$cp->expects($this->at(0))->method('_is_dir')->with('/subthemes/test-one')->will($this->returnValue(true));
$cp->expects($this->at(1))->method('_is_dir')->with('/subthemes/test-two')->will($this->returnValue(false));
$cp->setup_multicomic_partial_paths(1);
$this->assertEquals(array('/subthemes/test-one'), $cp->partial_paths);
}
示例2: submit_add_category
function submit_add_category($config)
{
$name = $_POST['name'];
$receipt = $_POST['type'] == "receipt" ? 1 : 0;
$description = $_POST['description'];
return add_category($config, $name, $receipt, $description);
}
示例3: testGetPostCategories
function testGetPostCategories()
{
global $comicpress_manager;
add_category(1, (object) array('name' => 'comics'));
add_category(2, (object) array('name' => 'comics2'));
// subdirectory
update_option('comicpress-manager-manage-subcomic', "2");
$comicpress_manager = $this->getMock('ComicPressManager', array('normalize_storyline_structure', 'get_subcomic_directory'));
$comicpress_manager->expects($this->once())->method('normalize_storyline_structure')->will($this->returnValue(array('category_tree' => array('0/1'))));
$comicpress_manager->properties = array('comiccat' => 1);
$comicpress_manager->expects($this->once())->method('get_subcomic_directory')->will($this->returnValue("comic2"));
$a = new ComicPressPostEditor();
$this->assertEquals(array(2), $a->post_categories);
// first in storyline
update_option('comicpress-manager-manage-subcomic', "0");
$comicpress_manager = $this->getMock('ComicPressManager', array('normalize_storyline_structure', 'get_subcomic_directory', 'get_cpm_option'));
$comicpress_manager->expects($this->once())->method('normalize_storyline_structure')->will($this->returnValue(array('category_tree' => array('0/1', '0/2'))));
$comicpress_manager->properties = array('comiccat' => 1);
$comicpress_manager->expects($this->once())->method('get_subcomic_directory')->will($this->returnValue(false));
$comicpress_manager->expects($this->once())->method('get_cpm_option')->with('cpm-default-comic-category-is-last-storyline')->will($this->returnValue(0));
$a = new ComicPressPostEditor();
$this->assertEquals(array(1), $a->post_categories);
// last in storyline
update_option('comicpress-manager-manage-subcomic', "0");
$comicpress_manager = $this->getMock('ComicPressManager', array('normalize_storyline_structure', 'get_subcomic_directory', 'get_cpm_option'));
$comicpress_manager->expects($this->once())->method('normalize_storyline_structure')->will($this->returnValue(array('category_tree' => array('0/1', '0/2'))));
$comicpress_manager->properties = array('comiccat' => 1);
$comicpress_manager->expects($this->once())->method('get_subcomic_directory')->will($this->returnValue(false));
$comicpress_manager->expects($this->once())->method('get_cpm_option')->with('cpm-default-comic-category-is-last-storyline')->will($this->returnValue(1));
$a = new ComicPressPostEditor();
$this->assertEquals(array(2), $a->post_categories);
}
示例4: testGetCategoriesToExclude
/**
* @dataProvider providerTestGetCategoriesToExclude
*/
function testGetCategoriesToExclude($input, $expected_output)
{
add_category(1, (object) array('slug' => 'one'));
add_category(2, (object) array('slug' => 'one'));
add_category(3, (object) array('slug' => 'one'));
$dbi = new ComicPressDBInterface();
$this->assertEquals($expected_output, $dbi->_get_categories_to_exclude($input));
}
示例5: testFindParents
/**
* @dataProvider providerTestFindParents
*/
function testFindParents($post_categories, $expected_result)
{
add_category(1, (object) array('slug' => 'root', 'parent' => 0));
add_category(2, (object) array('slug' => 'comic', 'parent' => 1));
add_category(3, (object) array('slug' => 'part-1', 'parent' => 2));
add_category(4, (object) array('slug' => 'blog', 'parent' => 1));
wp_set_post_categories(1, $post_categories);
$this->p->post = (object) array('ID' => 1);
$this->assertEquals($expected_result, $this->p->find_parents());
}
示例6: testSetComicCategories
function testSetComicCategories()
{
$dbi = ComicPressDBInterface::get_instance();
for ($i = 1; $i <= 4; ++$i) {
add_category($i, (object) array());
}
$dbi->set_comic_categories(array(2, 3));
$this->assertEquals(array(1, 2, 3, 4), $dbi->_all_categories);
$this->assertEquals(array(1, 4), $dbi->_non_comic_categories);
}
示例7: add_categories
function add_categories()
{
$category = filter_input(INPUT_POST, 'category_name');
if ($category == NULL) {
$error = "Invalid category name. Check name and try again.";
include 'view/error.php';
} else {
add_category($category);
header('Location: .?action=list_categories');
}
}
示例8: testHandleUpdate
/**
* @dataProvider providerTestHandleUpdate
*/
function testHandleUpdate($original, $change, $new)
{
$this->core->comicpress = $this->getMock('ComicPress', array('save', 'init'));
$this->core->comicpress->comicpress_options = array('comic_category_id' => 1, 'comic_dimensions' => '760x', 'rss_dimensions' => '350x', 'archive_dimensions' => '125x');
$this->core->comicpress->comicpress_options = array_merge($this->core->comicpress->comicpress_options, $original);
add_category(2, (object) array('name' => 'test'));
$_POST = $change;
$this->core->handle_update_comicpress_options($_POST['cp']);
foreach ($new as $key => $value) {
$this->assertEquals($value, $this->core->comicpress->comicpress_options[$key]);
}
}
示例9: setUp
function setUp()
{
global $comicpress_manager;
_reset_wp();
$comicpress_manager = $this->getMock('ComicPressManager', array('generate_example_date', 'get_subcomic_directory', 'normalize_storyline_structure'));
$comicpress_manager->expects($this->once())->method('generate_example_date');
$comicpress_manager->expects($this->once())->method('get_subcomic_directory')->will($this->returnValue(false));
$comicpress_manager->expects($this->once())->method('normalize_storyline_structure')->will($this->returnValue(array('category_tree' => array('0/1'))));
$comicpress_manager->properties = array('comiccat' => 1);
add_category(1, (object) array('name' => 'comic'));
$this->u = new ComicPressUpload();
}
示例10: testRemoveAllCategories
function testRemoveAllCategories()
{
global $wp_test_expectations;
update_option('default_category', 0);
for ($i = 0; $i < 5; ++$i) {
add_category($i, (object) array('slug' => 'test-' . $i));
}
$this->assertEquals(5, count($wp_test_expectations['categories']));
$this->pf->remove_all_categories();
$this->assertEquals(1, count($wp_test_expectations['categories']));
$result = get_category(0);
$this->assertTrue(isset($result->term_id));
}
示例11: testFindFile
/**
* @dataProvider providerTestFindFile
*/
function testFindFile($files_to_setup, $search_path, $post_categories, $expected_path_result)
{
global $post;
mkdir(vfsStream::url('root/parent/partials/comic/chapter-1'), 0777, true);
mkdir(vfsStream::url('root/child/partials/comic/chapter-1'), 0777, true);
foreach ($files_to_setup as $path) {
file_put_contents(vfsStream::url($path), "test");
}
_set_template_directory(vfsStream::url('root/parent'));
_set_stylesheet_directory(vfsStream::url('root/child'));
$post = (object) array('ID' => 1);
wp_set_post_categories(1, array(2));
add_category(1, (object) array('slug' => 'comic', 'parent' => 0));
add_category(2, (object) array('slug' => 'chapter-1', 'parent' => 1));
$this->assertEquals($expected_path_result, $this->cp->find_file('index.inc', $search_path, $post_categories));
}
示例12: testGenerateAdditionalCategoriesCheckboxes
function testGenerateAdditionalCategoriesCheckboxes()
{
global $comicpress_manager;
$comicpress_manager = $this->getMock("ComicPressManager", array('get_cpm_option'));
$comicpress_manager->properties['blogcat'] = 1;
$this->v->category_tree = array('0/2');
$comicpress_manager->expects($this->once())->method('get_cpm_option')->will($this->returnValue("4"));
add_category(3, (object) array('cat_name' => 'Test', 'parent' => 0));
add_category(4, (object) array('cat_name' => 'Test 2', 'parent' => 0));
$result = $this->v->_generate_additional_categories_checkboxes();
$this->assertTrue(count($result) == 2);
$this->assertTrue(count($this->v->category_checkboxes) == 2);
$this->assertTrue(($first = _to_xml($result[0])) !== false);
$this->assertTrue(_node_exists($first, '//label/input[@value="3" and not(@checked="checked")]'));
$this->assertTrue(($second = _to_xml($result[1])) !== false);
$this->assertTrue(_node_exists($second, '//label/input[@value="4" and @checked="checked"]'));
}
示例13: testRenderGenerationStates
function testRenderGenerationStates()
{
global $comicpress_manager, $comicpress_manager_admin;
add_category(1, (object) array('name' => 'Comics'));
add_category(2, (object) array('name' => 'Blog'));
$s = new ComicPressSidebarStandard();
$s->thumbnail_generation = array('rss' => true, 'archive' => array("test"));
$comicpress_manager_admin = $this->getMock('ComicPressManagerAdmin', array('show_debug_info'));
ob_start();
$s->render();
$source = ob_get_clean();
$this->assertTrue(($xml = _to_xml($source, true)) !== false);
foreach (array() as $xpath => $value) {
$this->assertTrue(_xpath_test($xml, $xpath, $value), $xpath);
}
$this->markTestIncomplete();
}
示例14: testProcessSearchString
/**
* @dataProvider providerTestProcessSearchString
*/
function testProcessSearchString($string, $expected_searches, $post_id_to_use = 1)
{
$fs = $this->getMock('ComicPressBackendFilesystemFactory', array('_replace_wordpress'));
$fs->expects($this->any())->method('_replace_wordpress')->will($this->returnValue('/wordpress'));
$posts = array(1 => (object) array('ID' => 1, 'post_date' => '2009-01-01'), 2 => (object) array('ID' => 2, 'post_date' => '2009-01-01'));
add_category(1, (object) array('slug' => 'parent', 'parent' => 0));
add_category(2, (object) array('slug' => 'child', 'parent' => 1));
add_category(4, (object) array('slug' => 'bad', 'parent' => 3));
wp_set_post_categories(1, array(2));
wp_set_post_categories(2, array(4));
update_option('upload_path', 'upload');
update_option('home', 'http://wordpress/');
$fs->search_string = $string;
$comicpress = ComicPress::get_instance(true);
$comicpress->comicpress_options = array('backend_options' => array('filesystem' => array('folders' => array('comic' => 'comic-folder'))));
$this->assertEquals($expected_searches, $fs->process_search_string($posts[$post_id_to_use], 'comic', 'filename.jpg'));
}
示例15: lang
$success = lang('success_edited_cat');
}
if (isset($_POST['add'])) {
// Convert checkboxes
if ($_POST['aop'] == "on") {
$_POST['aop'] = 1;
} else {
$_POST['aop'] = 0;
}
if ($_POST['aot'] == "on") {
$_POST['aot'] = 1;
} else {
$_POST['aot'] = 0;
}
// Results
$result = add_category($_POST['name'], $_POST['order'], $_POST['aop'], $_POST['aot']);
// Check Results
if ($result === "INVALID_ID") {
$error = lang_parse('error_invalid_given', array(lang('id')));
} else {
if (!$result) {
$error = lang('error_adding_cat');
}
}
// No errors?
if (!$error) {
$success = lang('success_cat');
}
}
/**
* Include header