Skip to content

Instantly share code, notes, and snippets.

View mark7651's full-sized avatar

Max mark7651

  • LPunity
View GitHub Profile
@sinyavsky
sinyavsky / install.php
Last active July 3, 2023 19:55 — forked from tschoffelen/install.php
A simple PHP script that automatically downloads and unzips the latest version of Wordpress in the current directory (./), so that I don't have to download it and upload it to my server through FTP manually.
<?php
// список плагинов для установки
$pluginsList = [
'contact-form-7',
'cyr2lat',
'flamingo',
'wp-fastest-cache',
'wordpress-seo'
@vladilenm
vladilenm / JavaScript Fetch.js
Last active March 1, 2024 02:28
JavaScript Fetch + XMLHttpRequest
const requestURL = 'https://jsonplaceholder.typicode.com/users'
function sendRequest(method, url, body = null) {
const headers = {
'Content-Type': 'application/json'
}
return fetch(url, {
method: method,
body: JSON.stringify(body),
@nikola-wd
nikola-wd / CommentFormProcessing.php
Last active March 12, 2023 20:11
Wordpress AJAX comment form in vanilla JS (es6) + axios (Comment submission without page refresh)
<?php
add_action( 'wp_ajax_ajaxcomments', 'ugwps_submit_ajax_comment' ); // wp_ajax_{action} for registered user
add_action( 'wp_ajax_nopriv_ajaxcomments', 'ugwps_submit_ajax_comment' ); // wp_ajax_nopriv_{action} for not registered users
function ugwps_submit_ajax_comment(){
$comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
if ( is_wp_error( $comment ) ) {
$error_data = intval( $comment->get_error_data() );
if ( ! empty( $error_data ) ) {
wp_die( '<p>' . $comment->get_error_message() . '</p>', __( 'Comment Submission Failure' ), array( 'response' => $error_data, 'back_link' => true ) );
@anwas
anwas / wordpress-facebook-opengraph.php
Last active October 22, 2022 08:50
[Facebook OpenGraph integracija WordPress temoje]
<?php
/**
* Adding the Open Graph in the Language Attributes
* @param $output
*
* @return string
*/
function mysite_add_opengraph_doctype( $output ) {
return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
}
@gschoppe
gschoppe / gjs-disable-attachment-pages.php
Last active January 18, 2024 13:49
WordPress plugin to properly disable attachment pages. This is not a redirect or forced 404. Attachment pages will simply not exist, and the slug will remain available for other posts and pages..
<?php if( ! defined( 'ABSPATH' ) ) { die(); }
/**
* Plugin Name: Disable Attachment Pages
* Plugin URI: https://gschoppe.com/wordpress/disable-attachment-pages
* Description: Completely disable attachment pages the right way. No forced redirects or 404s, no reserved slugs.
* Author: Greg Schoppe
* Author URI: https://gschoppe.com/
* Version: 1.0.0
**/