-
Notifications
You must be signed in to change notification settings - Fork 9
/
the-loops.php
146 lines (130 loc) · 3.93 KB
/
the-loops.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/**
* The Loops plugin
*
* The Loops allows you to query the WordPress database for content and display it in a page without having to write php code.
*
* @package The_Loops
*/
/**
* Plugin Name: The Loops
* Plugin URI: http://wordpress.org/plugins/the-loops/
* Description: The Loops allows you to query the WordPress database for content and display it in a page without having to write php code.
* Author: Ulrich Sossou
* Author URI: http://ulrichsossou.com/
* Version: 1.0.3
* License: GPL2 or later
* Text-domain: the-loops
*/
/* Copyright 2011 Ulrich Sossou (http://github.com/sorich87)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) )
exit;
if ( ! class_exists( 'The_Loops' ) ) :
/**
* Main plugin class
*
* @package The_Loops
* @since 0.1
*/
class The_Loops {
/**
* Class contructor
*
* @package The_Loops
* @since 0.1
*/
public function __construct() {
$this->setup_globals();
$this->includes();
$this->setup_hooks();
}
/**
* Global variables
*
* @package The_Loops
* @since 0.1
*/
private function setup_globals() {
$this->file = __FILE__;
$this->basename = plugin_basename( $this->file );
$this->plugin_dir = plugin_dir_path( $this->file );
$this->plugin_url = plugin_dir_url( $this->file );
$this->templates_dir = $this->plugin_dir . 'tl-templates/';
}
/**
* Required files
*
* @package The_Loops
* @since 0.1
*/
private function includes() {
require( $this->plugin_dir . 'tl-functions.php' );
require( $this->plugin_dir . 'tl-template-tags.php' );
require( $this->plugin_dir . 'tl-widget.php' );
if ( is_admin() )
require( $this->plugin_dir . 'tl-admin.php' );
}
/**
* Setup the plugin main functions
*
* @package The_Loops
* @since 0.1
*/
private function setup_hooks() {
add_action( 'init', array( $this, 'register_post_type' ) );
}
/**
* Register loop post type
*
* @package The_Loops
* @since 0.1
*/
public function register_post_type() {
$labels = array(
'name' => _x( 'Loops', 'post type general name' ),
'singular_name' => _x( 'Loop', 'post type singular name' ),
'add_new' => _x( 'Add New', 'loop' ),
'add_new_item' => __( 'Add New Loop' ),
'edit_item' => __( 'Edit Loop' ),
'new_item' => __( 'New Loop' ),
'all_items' => __( 'Loops' ),
'view_item' => __( 'View Loop' ),
'search_items' => __( 'Search Loops' ),
'not_found' => __( 'No loops found' ),
'not_found_in_trash' => __( 'No loops found in Trash' ),
'parent_item_colon' => '',
'menu_name' => __( 'Loops' )
);
$args = array(
'capabilities' => array(
'edit_post' => 'edit_theme_options',
'delete_post' => 'edit_theme_options',
'read_post' => 'read',
'edit_posts' => 'edit_theme_options',
'edit_others_posts' => 'edit_theme_options',
'publish_posts' => 'edit_theme_options',
'read_private_posts' => 'edit_theme_options'
),
'labels' => $labels,
'show_ui' => true,
'show_in_menu' => 'themes.php',
'supports' => array( 'title' )
);
register_post_type( 'tl_loop', $args );
}
}
$GLOBALS['the_loops'] = new The_Loops();
endif;