Skip to content

Instantly share code, notes, and snippets.

View elpuas's full-sized avatar
💻
coding

Alfredo Navas-Fernandini elpuas

💻
coding
View GitHub Profile
node index.js
const http = require( 'http' )
// Create and start a server with the
// createServer method from http package
const server = http.createServer( ( req, res ) => {
console.log(req.url)
res.end( 'Hello node.js' )
} )
// start our server to start taking request
mkdir my-cool-app && cd my-cool-app && touch index.js
@elpuas
elpuas / .install-node
Created April 1, 2021 20:40
Install Node
# Install node with Brew:
brew install node
node -v
@elpuas
elpuas / Disable RichText Formats
Last active February 10, 2021 14:45
Gutenberg Disable RichText Formats
wp.domReady( function() {
wp.richText.unregisterFormatType( 'core/bold' );
wp.richText.unregisterFormatType( 'core/italic' );
wp.richText.unregisterFormatType( 'core/strikethrough' );
wp.richText.unregisterFormatType( 'core/subscript' );
wp.richText.unregisterFormatType( 'core/superscript' );
wp.richText.unregisterFormatType( 'core/text-color' );
wp.richText.unregisterFormatType( 'core/image' );
wp.richText.unregisterFormatType( 'core/underline' );
wp.richText.unregisterFormatType( 'core/code' );
@elpuas
elpuas / get-first-category.php
Created February 25, 2020 17:05 — forked from hslaszlo/get-first-category.php
Get first category name or id from wordpress post
<?php
// in the loop
$category = get_the_category();
$currentcat = $category[0]->cat_ID;
$currentcatname = $category[0]->cat_name;
$currentcatslug = $category[0]->slug;
// outside the loop
global $post;
$categories = get_the_category($post->ID);
@elpuas
elpuas / remove-editor-panels.js
Created November 14, 2019 00:35
remove editor panels
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'taxonomy-panel-category' ) ; // category
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'taxonomy-panel-TAXONOMY-NAME' ) ; // custom taxonomy
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'taxonomy-panel-post_tag' ); // tags
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'featured-image' ); // featured image
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'post-link' ); // permalink
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'page-attributes' ); // page attributes
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'post-excerpt' ); // Excerpt
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'discussion-panel' ); // Discussion
@elpuas
elpuas / function.php
Created June 29, 2019 23:42 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
// Add to existing function.php file
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
// Trim Homepage cards on Mobile
// if ($(window).width() < 700) {
// // Select Each Card Section
// let cardsSel = $('[class^="sec-"] .category__card-title');
// // Get Only THe Items after the First Child
// let divToTrim = $.grep(cardsSel, function (x, index) {
// return (index % 4) != 0;
// });
// // Iterate over the array and get the Text
// Hide Admin Items
add_action('admin_head', 'mdo_adminizer');
function mdo_adminizer(){
global $current_user;
get_currentuserinfo();
if ( $current_user->user_email !== "[email protected]" ) {
echo '<style>