reportaprod /blog/wp-content/themes/monochrome/functions.php

Language PHP Lines 314
MD5 Hash 34b3a007036825120a2d26ad59090dd5 Estimated Cost $4,385 (why?)
Repository https://bitbucket.org/sergiohzlz/reportaprod View Raw File View Project SPDX
  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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<?php

$content_width = 510;

add_theme_support( 'automatic-feed-links' );

// Custom background
add_custom_background();

// Load scripts

function theme_scripts_init() {
	if (!is_admin()) { // if this isn't the WordPress admin
		// load jQuery		
		wp_enqueue_script('jquery');

		// load theme scripts
		wp_enqueue_script('jquery_easing', get_bloginfo('template_url') . '/js/jquery.easing.js', array('jquery'));
		wp_enqueue_script('theme_scripts', get_bloginfo('template_url') . '/js/jscript.js', array('jquery'));
		wp_enqueue_script('comment_scripts', get_bloginfo('template_url') . '/js/comment.js?1', array('jquery'));		
	}
}
add_action('init', 'theme_scripts_init');

register_nav_menus( array(
	'primary' => __( 'Primary Navigation', 'monochrome' ),
) );

function monochrome_page_menu() { // fallback for primary navigation ?>
<ul class="menu" id="menu">
     <li class="<?php if (!is_paged() && is_home()) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="<?php echo home_url( '/' ); ?>"><?php _e('HOME','monochrome'); ?></a></li>
     <?php
         $options = get_option('mc_options');
         if ( 'pages' == $options['header_menu_type'] ) {
         	wp_list_pages( 'sort_column=menu_order&depth=0&title_li=&exclude=' . $options['exclude_pages'] );
         } else {
         	wp_list_categories( 'depth=0&title_li=&&exclude=' . $options['exclude_category'] );
         }
     ?>
</ul>
<?php }


// Theme option

class monochrome_options {

	function getOptions() {
		$options = get_option('mc_options');
		if (!is_array($options)) {
			$options['show_information'] = true;
			$options['information_title'] = '';
			$options['information_contents'] = '';
			$options['rss_feed'] = true;
			$options['search_position'] = 'top';
			$options['tag_list'] = false;
			$options['header_menu_type'] = 'pages';
			$options['author'] = false;
			$options['tag'] = true;
			$options['pagetop'] = true;
			$options['exclude_pages'] = '';
			$options['exclude_category'] = '';
			update_option('mc_options', $options);
		}
		return $options;
	}

	function update() {
		if(isset($_POST['pb_save'])) {
			$options = monochrome_options::getOptions();

			// information
			if ($_POST['show_information']) {
				$options['show_information'] = (bool)true;
			} else {
				$options['show_information'] = (bool)false;
			}
			$options['information_title'] = esc_attr(stripslashes($_POST['information_title']));
			$options['information_contents'] = stripslashes(wp_filter_post_kses($_POST['information_contents']));
			if ($_POST['rss_feed']) {
				$options['rss_feed'] = (bool)true;
			} else {
				$options['rss_feed'] = (bool)false;
			}

			// search
			$options['search_position'] = esc_attr(stripslashes($_POST['search_position']));
			if ($_POST['tag_list']) {
				$options['tag_list'] = (bool)true;
			} else {
				$options['tag_list'] = (bool)false;
			}

			// header menu
			$options['header_menu_type'] = esc_attr(stripslashes($_POST['header_menu_type']));

			// exclude pages
			$options['exclude_pages'] = esc_attr(stripslashes($_POST['exclude_pages']));

			// exclude category
			$options['exclude_category'] = esc_attr(stripslashes($_POST['exclude_category']));

			// show author
			if ($_POST['author']) {
				$options['author'] = (bool)true;
			} else {
				$options['author'] = (bool)false;
			}

			// show tag
			if ($_POST['tag']) {
				$options['tag'] = (bool)true;
			} else {
				$options['tag'] = (bool)false;
			}

			// show pagetop link
			if ($_POST['pagetop']) {
				$options['pagetop'] = (bool)true;
			} else {
				$options['pagetop'] = (bool)false;
			}

			update_option('mc_options', $options);

		} else {
			monochrome_options::getOptions();
		}

		add_theme_page(__('Theme Options', 'monochrome'), __('Theme Options', 'monochrome'), 'edit_theme_options', basename(__FILE__), array('monochrome_options', 'display'));
	}

	function display() {
		$options = monochrome_options::getOptions();
?>

<div class="wrap">

<h2><?php _e('Monochrome option', 'monochrome'); ?></h2>

<form method="post" action="#" enctype="multipart/form-data">

<p><?php _e('Show Information on sidebar.', 'monochrome'); ?></p>
<p>
<input name="show_information" type="checkbox" value="checkbox" <?php if($options['show_information']) echo "checked='checked'"; ?> /><?php _e('Yes', 'monochrome'); ?><br />
</p>
<br />

<p><?php _e('Information title.', 'monochrome'); ?></p>
<p><input type="text" name="information_title" value="<?php echo($options['information_title']); ?>" /></p>
<br />

<p><?php _e('Information contents. ( HTML tag is available. )', 'monochrome'); ?></p>
<p><textarea name="information_contents" cols="70%" rows="5"><?php echo( esc_textarea( $options['information_contents'] ) ); ?></textarea></p>
<br />

<p><?php _e('Show rss feed on sidebar.', 'monochrome'); ?></p>
<p>
<input name="rss_feed" type="checkbox" value="checkbox" <?php if($options['rss_feed']) echo "checked='checked'"; ?> /><?php _e('Yes', 'monochrome'); ?><br />
</p>
<br />

<p><?php _e('Position of search area on sidebar.', 'monochrome'); ?></p>
<p>
<input name="search_position" type="radio" value="top" <?php if($options['search_position'] != 'bottom') echo "checked='checked'"; ?> /><?php _e('Top', 'monochrome'); ?><br />
<input name="search_position" type="radio" value="bottom" <?php if($options['search_position'] == 'bottom') echo "checked='checked'"; ?> /><?php _e('Bottom', 'monochrome'); ?>
</p>
<br />

<p><?php _e('Show tag list under search area.', 'monochrome'); ?></p>
<p>
<input name="tag_list" type="checkbox" value="checkbox" <?php if($options['tag_list']) echo "checked='checked'"; ?> /><?php _e('Yes', 'monochrome'); ?><br />
</p>
<br />

<p><?php _e('Header menu.', 'monochrome'); ?></p>
<p>
<input name="header_menu_type" type="radio" value="pages" <?php if($options['header_menu_type'] != 'categories') echo "checked='checked'"; ?> /><?php _e('Use pages for header menu.', 'monochrome'); ?><br />
<input name="header_menu_type" type="radio" value="categories" <?php if($options['header_menu_type'] == 'categories') echo "checked='checked'"; ?> /><?php _e('Use categories for header menu.', 'monochrome'); ?>
</p>
<p><em><?php _e('This option may produce undesired results.'); ?></em></p>
<br />

<p><?php _e('Exclude Pages (Page ID\'s you don\'t want displayed in your header navigation. Use a comma-delimited list, eg. 1,2,3)', 'monochrome'); ?></p>
<p><input type="text" name="exclude_pages" value="<?php echo($options['exclude_pages']); ?>" /></p>
<br />

<p><?php _e('Exclude Categories (Category ID\'s you don\'t want displayed in your header navigation. Use a comma-delimited list, eg. 1,2,3)', 'monochrome'); ?></p>
<p><input type="text" name="exclude_category" value="<?php echo($options['exclude_category']); ?>" /></p>
<br />

<p><?php _e('Show author name.', 'monochrome'); ?></p>
<p>
<input name="author" type="checkbox" value="checkbox" <?php if($options['author']) echo "checked='checked'"; ?> /><?php _e('Yes', 'monochrome'); ?><br />
</p>
<br />

<p><?php _e('Show tag.', 'monochrome'); ?></p>
<p>
<input name="tag" type="checkbox" value="checkbox" <?php if($options['tag']) echo "checked='checked'"; ?> /><?php _e('Yes', 'monochrome'); ?><br />
</p>
<br />

<p><?php _e('Check if you want to show Return top link.<br />( NOTICE : Return top link does not work on IE6. )', 'monochrome'); ?></p>
<p><input name="pagetop" type="checkbox" value="checkbox" <?php if($options['pagetop']) echo "checked='checked'"; ?> /><?php _e('Yes', 'monochrome'); ?></p>
<br />
<br />

<p><input class="button-primary" type="submit" name="pb_save" value="<?php _e('Save Changes', 'monochrome'); ?>" /></p>

</form>

</div>

<?php
  }
}

// register functions
add_action('admin_menu', array('monochrome_options', 'update'));


// for localization
load_textdomain('monochrome', dirname(__FILE__).'/languages/' . get_locale() . '.mo');


// Sidebar widget
if ( function_exists('register_sidebar') )
    register_sidebar(array(
        'before_widget' => '<div class="side_box" id="%1$s">'."\n",
        'after_widget' => "</div>\n",
        'before_title' => '<h3>',
        'after_title' => "</h3>\n",
    ));


// Remove [...] from excerpt
function trim_excerpt($text) {
  return rtrim($text,'[...]');
}
add_filter('get_the_excerpt', 'trim_excerpt');

function custom_comments($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment;
	global $commentcount;
	if(!$commentcount) {
		$commentcount = 0;
	}
?>

 <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
  <div class="comment-meta">
   <div class="comment-meta-left">
  <?php if (function_exists('get_avatar') && get_option('show_avatars')) { echo get_avatar($comment, 35); } ?>
  
    <ul class="comment-name-date">
     <li class="comment-name">
<?php if (get_comment_author_url()) : ?>
<a id="commentauthor-<?php comment_ID() ?>" class="url <?php if($comment->comment_author_email == get_the_author_email()) {echo 'admin-url';} else {echo 'guest-url';} ?>" href="<?php comment_author_url() ?>" rel="external nofollow">
<?php else : ?>
<span id="commentauthor-<?php comment_ID() ?>">
<?php endif; ?>

<?php comment_author(); ?>

<?php if(get_comment_author_url()) : ?>
</a>
<?php else : ?>
</span>
<?php endif; ?>
     </li>
     <li class="comment-date"><?php echo get_comment_time(__('F jS, Y', 'monochrome')); ?></li>
    </ul>
   </div>

   <ul class="comment-act">
<?php if (function_exists('comment_reply_link')) { 
        if ( get_option('thread_comments') == '1' ) { ?>
    <li class="comment-reply"><?php comment_reply_link(array_merge( $args, array('add_below' => 'comment-content', 'depth' => $depth, 'max_depth' => $args['max_depth'], 'reply_text' => '<span><span>'.__('REPLY','monochrome').'</span></span>'.$my_comment_count))) ?></li>
<?php   } else { ?>
    <li class="comment-reply"><a href="javascript:void(0);" onclick="MGJS_CMT.reply('commentauthor-<?php comment_ID() ?>', 'comment-<?php comment_ID() ?>', 'comment');"><?php _e('REPLY', 'monochrome'); ?></a></li>
<?php   }
      } else { ?>
    <li class="comment-reply"><a href="javascript:void(0);" onclick="MGJS_CMT.reply('commentauthor-<?php comment_ID() ?>', 'comment-<?php comment_ID() ?>', 'comment');"><?php _e('REPLY', 'monochrome'); ?></a></li>
<?php } ?>
    <li class="comment-quote"><a href="javascript:void(0);" onclick="MGJS_CMT.quote('commentauthor-<?php comment_ID() ?>', 'comment-<?php comment_ID() ?>', 'comment-content-<?php comment_ID() ?>', 'comment');"><?php _e('QUOTE', 'monochrome'); ?></a></li>
    <?php edit_comment_link(__('EDIT', 'monochrome'), '<li class="comment-edit">', '</li>'); ?>
   </ul>

  </div>
  <div class="comment-content" id="comment-content-<?php comment_ID() ?>">
  <?php if ($comment->comment_approved == '0') : ?>
   <span class="comment-note"><?php _e('Your comment is awaiting moderation.', 'monochrome'); ?></span>
  <?php endif; ?>
  <?php comment_text(); ?>
  </div>

<?php }

function widget_monochrome_search() {
?>
	<div class="side_box" id="search_area_top">
   <div id="search_area" class="clearfix">
    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
     <div><input type="text" value="<?php _e('Search','monochrome'); ?>" name="s" id="search_input" onfocus="this.value=''; changefc('white');" /></div>
     <div><input type="image" src="<?php bloginfo('template_url'); ?>/img/search_button_n.gif" alt="<?php _e('Search from this blog.','monochrome'); ?>" title="<?php _e('Search from this blog.','monochrome'); ?>" id="search_button" /></div>
    </form>
   </div>
</div>
<?php
}
unregister_widget('WP_Widget_Search');
wp_register_sidebar_widget('search', __('Search'), 'widget_monochrome_search');
Back to Top