Skip to content

Instantly share code, notes, and snippets.

View danielpataki's full-sized avatar

Daniel Pataki danielpataki

View GitHub Profile
@danielpataki
danielpataki / footer.php
Created January 10, 2017 20:07
Simple theme for customizer project
@danielpataki
danielpataki / custom-post-type-features.php
Last active December 2, 2022 08:49
Custom Post Type Example
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' );
@danielpataki
danielpataki / acf-notice.php
Last active November 1, 2022 07:35
Admin Notices
if( !function_exists( 'the_field' ) && empty( get_option( 'my-acf-notice-dismissed' ) ) ) {
add_action( 'admin_notices', 'my_acf_admin_notice' );
}
function my_acf_admin_notice() {
?>
<div class="notice error my-acf-notice is-dismissible" >
<p><?php _e( 'ACF is not necessary for this plugin, but it will make your experience better, install it now!', 'my-text-domain' ); ?></p>
</div>
$token = get_transient( 'twitter_access_token' );
$token = ( empty( $token ) ) ? get_twitter_access_token() : $token;
$request = wp_remote_get('https://api.twitter.com/1.1/followers/ids.json?screen_name=danielpataki&count=5', array(
'headers' => array(
'Authorization' => 'Bearer ' . $token,
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
),
'httpversion' => '1.1'
));
$token = json_decode( $request['body'] );
$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>',
@danielpataki
danielpataki / add-help-text.php
Last active January 27, 2022 09:45
Simplify the admin
function my_post_guidelines() {
$screen = get_current_screen();
if ( 'post' != $screen->post_type )
return;
$args = array(
'id' => 'my_website_guide',
'title' => 'Content Guidelines',
@danielpataki
danielpataki / delete-tax.php
Last active August 28, 2021 01:06
Database cleaning
DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy IN ( 'unwanted_tax_1', 'unwanted_tax_2' ) );
DELETE FROM wp_term_relationships WHERE term_taxonomy_id IN (SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE taxonomy IN ( 'unwanted_tax_1', 'unwanted_tax_2' ) );
DELETE FROM wp_term_taxonomy WHERE taxonomy IN ( 'unwanted_tax_1', 'unwanted_tax_2' );
@danielpataki
danielpataki / basic-deactivation.php
Last active July 4, 2021 17:30
Installation And Uninstallation Hooks
register_deactivation_hook( __FILE__, 'my_plugin_deactivation' );
function my_plugin_deactivation() {
// Deactivation rules here
}
@danielpataki
danielpataki / ajax-action.php
Last active April 17, 2021 14:02
Twenty Fifteen AJAX
add_action( 'wp_ajax_nopriv_ajax_pagination', 'my_ajax_pagination' );
add_action( 'wp_ajax_ajax_pagination', 'my_ajax_pagination' );
function my_ajax_pagination() {
echo get_bloginfo( 'title' );
die();
}
@danielpataki
danielpataki / activation.php
Last active February 22, 2021 16:21
WordPress Custom Database Tables
register_activation_hook( __FILE__, 'my_plugin_create_db' );
function my_plugin_create_db() {
// Create DB Here
}