Skip to content

<?php
class Animal{
protected $name;
protected function __construct($name){
$this->name = $name;
}
@komagata
komagata / array_cat.php
Created December 28, 2011 11:30
array cat
<?php
$foo = array();
$a = array(1,2,3);
$b = array(4,5,6);
$foo += $a;
$foo += $b;
print_r($foo);
?>
// result
function get_custom_cat_template($single_template) {
global $post;
if ( in_category( 'category-name' )) {
$single_template = dirname( __FILE__ ) . '/single-template.php';
}
return $single_template;
}
add_filter( "single_template", "get_custom_cat_template" ) ;
@chillbits-legacy
chillbits-legacy / your-plugin-main-file.php
Last active January 27, 2016 18:56
Multiple categories rewrite rules in WordPress. Example: /cat/child-cat/grandchild-cat/cpt-name/
<?php
class Your_Plugin {
/**
* Post Type slug modification
*
* @since 1.0.0
* @return null
*/
function modifySlug($link, $post)
{
@BoldBigflank
BoldBigflank / gist:2175093
Created March 23, 2012 21:11
Cat Fact SMS
<?php
// Get a greeting based on the body
$Body = $_GET['Body'];
if(stripos($Body, "e4n3m23pd90vc4:9nfaDFADFD42baconP0o") !== FALSE){
$greeting = "&lt;Command not recognized&gt; ";
}
else if(stripos($Body, "stop") !== FALSE || strlen($Body)>30){
$greeting = "Hammer time. ";
}
@hoanganh25991
hoanganh25991 / Cat.php
Last active October 29, 2015 14:04
Laravel: Model Cat
<?php
class Cat extends Eloquent {
protected $fillable = array('name','date_of_birth','breed_id');
public function breed(){
return $this->belongsTo('Breed');
}
}
@laras126
laras126 / gist:965069
Created May 10, 2011 18:27
blog cat option
<?
// Which category will be the blog page?
$options[] = array( "name" => "Blog Category",
"desc" => "Select the category that will be blog posts. All other categories will be in the portfolio format.",
"id" => $shortname."_cats_in_blog",
"std" => "",
"type" => "select",
"options" => $of_categories);
@spivurno
spivurno / gp-copy-cat-gpcc_copy_cat_fields.php
Last active October 15, 2021 15:45
Gravity Perks // GP Copy Cat // Filter Copy Cat Fields
<?php
/**
* Gravity Perks // GP Copy Cat // Filter Copy Cat Fields
* http://gravityperks.com/
*/
add_filter( 'gpcc_copy_cat_fields_126', function( $fields, $form ) {
$fields[44] = array(
array(
'source' => 44,
@Stiofan
Stiofan / cat_map_marker.php
Last active November 10, 2016 16:11
Make map on GD cat pages show marker of cat and not main cat of post
<?php
add_filter('geodir_create_marker_jason_of_posts','_my_change_cat_map_markers_to_current_cat',11,2);
function _my_change_cat_map_markers_to_current_cat($marker_json,$post){
global $gd_cur_term_icon_url;
if(geodir_is_page('listing') && is_tax()){
if(!$gd_cur_term_icon_url){
$term_icon_url = get_tax_meta(get_queried_object()->term_id, 'ct_cat_icon', false, $post->post_type);
@mdjwel
mdjwel / category_array.php
Created May 22, 2018 08:51
Get associative array (cat_slug => cat_name) in WordPress
<?php
// Category array
function chaoz_cat_array($term='portfolio_cat') {
$cats = get_terms(array(
'taxonomy' => $term,
'hide_empty' => true
));
$cat_array = array();
$cat_array['all'] = esc_html__('All', 'gullu');
foreach ($cats as $cat) {