Skip to content

Instantly share code, notes, and snippets.

View danielpataki's full-sized avatar

Daniel Pataki danielpataki

View GitHub Profile
@danielpataki
danielpataki / alt-cron.php
Last active October 9, 2024 00:33
WordPress Config File
define( 'ALTERNATE_WP_CRON', true );
@danielpataki
danielpataki / full-code.php
Last active October 9, 2024 00:26
Adding Your Own welcome screen
register_activation_hook( __FILE__, 'welcome_screen_activate' );
function welcome_screen_activate() {
set_transient( '_welcome_screen_activation_redirect', true, 30 );
}
add_action( 'admin_init', 'welcome_screen_do_activation_redirect' );
function welcome_screen_do_activation_redirect() {
// Bail if no activation redirect
if ( ! get_transient( '_welcome_screen_activation_redirect' ) ) {
return;
@danielpataki
danielpataki / add-help-text.php
Last active August 1, 2024 23:43
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 / 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 / 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
}