wordpress OOP programming

wordpress de oop olarak eklenti yazmak

<?php
class Functions {
	public function __construct() {
		$this->theme_setup ();
		$this->add_action ();
	}

	/**
	 * initial theme setup
	 */
	public function theme_setup() {
		$default_image = get_template_directory_uri () . '/img/bg.png';
		add_theme_support ( 'custom-background', array (
				'default_image',
				$default_image
		) );
		add_theme_support ( 'post-formats', array (
				'aside',
				'image',
				'link'
		) );
		add_theme_support ( 'automatic-feed-links' );
		//add_theme_support ( 'post-thumbnails' );
	//	add_theme_support ( 'homepage-thumbnail', 500, 220, true );
		add_theme_support ( 'custom-header' );
		add_editor_style ( get_template_directory_uri () . 'editor-style.css' );
		// load_textdomain($domain, $mofile)
		if (! isset ( $content_with ))
			$content_with = 900;
	}
	public function add_action() {
		// regsiter sidebar
		add_action ( 'widgets_init', array (
				$this,
				'register-sidebar'
		) );
		// register_menu
		add_action ( 'init', array (
				$this,
				'register_menus'
		) );
		add_action ( 'wp_enqueue_scripts', array (
				$this,
				'load_scripts'
		) );
		// the page title  dfd
		add_action ( 'wp_title', array (
				$this,
				'page-title'
		) );

		// custom excerpt_lenght
		/*add_filter ( 'excerpt_lenght', array (
				$this,
				'excerpt_length'
		) );*/
	}
	public function load_scripts() {
		wp_register_style ( 'stylesheet', get_template_directory_uri () . '/style.css' );
		wp_enqueue_style ( 'stylesheet' );
		wp_enqueue_script ( 'jquery' );
		wp_register_script ( 'main', get_template_directory_uri () . '/js/main.js' );
		wp_enqueue_script ( 'main' );
	}
	public function register_menus() {
		register_nav_menus ( array (
				'primary' => __ ( 'Main Menu', 'gazpo' )
		) );

		register_nav_menus ( array (
				'footer' => __ ( 'Footer Menu', 'gazpo' )
		) );
	}
	public function register_sidebar() {
		register_sidebar ( array (
				'name' => __ ( 'Main Menu', 'gazpo' ),
				'id' => 'primary',
				'before_widget' => '',
				'after_widget' => '',
				'before_title' => '',
				'after_title' => ''
		) );
	}
	public static function page_title(){
		global $page,$paged;
		if (is_feed())
			return $title;
		$site_decription=get_bloginfo('name');
		$filtered_title=$title.get_bloginfo('name');

		return $filtered_title;
	}
}
$function = new Functions ();
Scroll to Top