Skip to content

Instantly share code, notes, and snippets.

Daniel Pataki danielpataki

Block or report user

Report or block danielpataki

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View custom-post-type-features.php
function my_custom_post_types() {
$args = array(
'label' => 'Recipes',
'hierarchical' => true,
'taxonomies => array( 'post_tag' )
);
register_post_type( 'recipe', $args );
}
add_action( 'init', 'my_custom_post_types' );
View custom-page-templates-alphabetical.php
<?php
/**
* Template Name: Alphabetical Posts
*/
get_header(); ?>
<div id="main-content" class="main-content">
<?php
View post-list-template-acf-options.php
if(function_exists("register_field_group"))
{
register_field_group(array (
'id' => 'acf_post-list-options',
'title' => 'Post List Options',
'fields' => array (
array (
'key' => 'field_543f8a046d65e',
'label' => 'Authors',
'name' => 'authors',
View customizing-comment-forms-fields.php
$args = array(
'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>'
'fields' => apply_filters( 'comment_form_default_fields', array(
'author' =>
'<p class="comment-form-author">' .
'<label for="author">' . __( 'Name', 'domainreference' ) . '</label> ' .
( $req ? '<span class="required">*</span>' : '' ) .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) .
'" size="30"' . $aria_req . ' /></p>',
View enqueue-register.php
function my_assets() {
wp_register_script( 'owl-carousel', get_stylesheet_directory_uri() . '/owl.carousel.js', array( 'jquery' ) );
wp_enqueue_script( 'owl-carousel' );
}
add_action( 'wp_enqueue_scripts', 'my_assets' );
@danielpataki
danielpataki / custom.php
Last active Aug 29, 2015
Editor Style Examples
View custom.php
function my_editor_styles() {
add_editor_style( 'admin/editor.css' );
}
add_action( 'after_setup_theme', 'my_editor_styles' );
@danielpataki
danielpataki / action.php
Last active Nov 27, 2016
WordPress Emails
View action.php
function set_mail_html_content_type() {
return 'text/html';
}
add_action( 'publish_post', 'author_publish_notice', 10 ,2 );
function author_publish_notice( $ID, $post ) {
if( 'post' == $post->post_type ) {
return;
}
View commentcount.php
global $wpdb;
for( $i=1; $i <= 5; $i++ ) {
$this_week = 7 * $i;
$last_week = 7 * ( $i - 1);
$comment_counts[] =
$wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_date > '" . date('Y-m-d H:i:s', strtotime('-' . $this_week . ' days')) . "' AND comment_date < '" . date('Y-m-d H:i:s', strtotime('-' . $last_week . ' days')) . "'" ) ;
View basic-shortcode.php
function my_code_output( $atts, $content ) {
return '<pre><code>' . $content . '</code></pre>';
}
add_shortcode('code', 'my_code_output');
@danielpataki
danielpataki / admin-targeting-hook.php
Last active Aug 29, 2015
Common WordPress Code Mistakes
View admin-targeting-hook.php
function user_edit_script( $hook ) {
if ( 'profile.php' != $hook ) {
return;
}
wp_enqueue_script( 'my-user-edit', plugin_dir_url( __FILE__ ) . 'js/my-user-edit.js' );
}
add_action( 'admin_enqueue_scripts', 'user_edit_script' );
You can’t perform that action at this time.