Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: adh klausimai

Parašė adh· 2010 Spa. 2 18:10:33
#5


<?php
 
$includes = array(
	'lp_options' => LP_DIR.'lib/admin/options.php',
);
if ($_GET['page'] && isset($includes[$_GET['page']]))
{
	require_once($includes[$_GET['page']]);
}
 
 
add_action('admin_menu', 'lp_admin_menu');
 
 
 
// Add theme options menu item
function lp_admin_menu()
{
	$page = add_theme_page(LP_NAME.' '.__('Options'), LP_NAME.' '.__('Options'), 'edit_themes', 'lp_options', 'lp_admin_options');
 
	add_action('admin_print_styles-'.$page, 'lp_admin_styles');
	add_action('admin_footer-'.$page, 'lp_admin_scripts');
 
 
	if (defined('LP_OPTIONS') && (!empty($_FILES) || !empty($_POST)))
	{
		$fields = lp_admin_get_fields($_POST['prefix']);
		if (count($fields))
		{
			lp_admin_process_changes($_POST['prefix'], $fields);
		}
	}
}
 
 
// Add stylesheets
function lp_admin_styles()
{
	lp_print_script('admin', 'css');
 
	wp_enqueue_script('jquery');    
}
 
 
// Add javscripts
function lp_admin_scripts()
{
	lp_print_script('admin', 'js');
}
 
 
// Get admin page URL
function get_admin_link($type)
{
	return get_option('siteurl').'/wp-admin/themes.php?page='.$type;
}
 
 
// Reset cache files
function lp_reset_cache($parts, $ext)
{
	$dir = LP_DIR.'cache/';
 
	$d = opendir($dir);
	while ($file = readdir($d)) {
		if (is_file($dir.$file) && preg_match('~('.join('|', $parts).').*\.'.$ext.'$~i', $file)) 
		{
			unlink($dir.$file);
		}
	}
}
 
 
 
function lp_get_pages()
{
	$pages = get_pages(array());
	$levels = array();
	foreach ($pages as $item)
	{
		$level = 0;
		if ($item->post_parent && isset($levels[$item->post_parent]))
			$level = $levels[$item->post_parent] + 1;
 
		$items[] = array(
			'id' => $item->ID,
			'name' => $item->post_title,
			'level' => $level
		);
 
		$levels[$item->ID] = $level;
	}
 
	return $items;
}
 
function lp_get_categories()
{
	$categs = get_categories(array('hide_empty' => false));
	$levels = array();
	foreach ($categs as $item)
	{
		$level = 0;
		if ($item->category_parent && isset($levels[$item->category_parent]))
			$level = $levels[$item->category_parent] + 1;
 
		$items[] = array(
			'id' => $item->cat_ID,
			'name' => $item->name,
			'level' => $level
		);
 
		$levels[$item->ID] = $level;
	}
 
	return $items;
}
 
 
 
// initialize the upload directory
 
$uploadDir = lp_get_upload_dir();
if (!is_dir($uploadDir)) {
	mkdir($uploadDir, 0777);
}
 
 
?>