Wednesday, 4 January 2023

ngFor

untuk buat ngFor row dan col. Jadikan ROW sebagai ngFor manakala col pula untuk render data. example:-
Vector2632

Thursday, 6 October 2022

SHORTCODE Content Base on User Role/ User Log in

function member_only_shortcode($atts, $content = null) { if (is_user_logged_in() && !is_null($content) && !is_feed()) { return $content; } } add_shortcode('member_only', 'member_only_shortcode');
[member_only]User is logged in.[/member_only]

Tuesday, 28 June 2022

ENABLE USER UPLOAD ZIP

 Add this on functions.php


add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
    // add your extension to the mimes array as below
    $existing_mimes['zip'] = 'application/zip';
    $existing_mimes['gz'] = 'application/x-gzip';
    return $existing_mimes;
}

Thursday, 14 April 2022

WP PLUGIN DEVELOPMENT

  1.  Looking method to get data from wp-mysql
  2. create form to adjust wp-mysql from admin side
  3. connect with woocommerce
1. GET DATA FROM MYSQL

add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');
function my_custom_dashboard_widgets() {
global $wp_meta_boxes;
wp_add_dashboard_widget('custom_help_widget', 'Custom Plugin', 'custom_dashboard_help');
}

function custom_dashboard_help() {
global $wpdb;

//insert first row as ID so that we can update database later with form
$wpdb->get_row( $wpdb->prepare( "INSERT INTO wp_pluck SET ID=1" ) ); 

//using iframe to connect with backdoor plugin form
echo '<iframe src="http://localhost/optimize/wp-content/plugins/godek/godek-update.php" title="Embed Inside Admin"></iframe>';

// *optional, for display echo or debug
$pluck = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM wp_pluck WHERE ID = 1" ) );
echo $pluck->number; 
}

2. UPDATE WPDB ROW 

$wpdb->get_row( $wpdb->prepare( "UPDATE wp_pluck SET number='3' WHERE id=1" ) );

3. IN PLUGIN FOLDER CREATE PHP FILE

FORM FILE

<?php
//create godek-update.php to update

$produk_id=1;

$servername = "localhost";
$username = "root";
$password = "";
$db = "optimize";

$conn = new mysqli($servername, $username, $password, $db);

if($conn->connect_error){
die("Connection failed ".$conn->connect_error);
}

$sql = "select * from wp_pluck where id='$produk_id'";

$result = $conn->query($sql);

if ($result->num_rows > 0){

$row = $result->fetch_assoc();

$number = $row["number"];
echo

"<html>
<body>

<form action='godek-process.php' method='post'>
Student ID: $produk_id<br>
<input type='hidden' name='produk_id' value='$produk_id'>
Name: <input type='text' name='number' value='$number'><br>
<input type ='submit'>
</form>

</body>
</html>";

} else {
echo "Not Found";
}
$conn->close();

?>



EXECUTE FILE

<?php
//create godek-process.php execute

$produk_id = $_POST["produk_id"];
$number = $_POST["number"];

$servername = "localhost";
$username = "root";
$password = "";
$db = "optimize";

$conn = new mysqli($servername, $username, $password, $db);

if ($conn->connect_error){
die("Connection failed: ". $conn->connect_error);
}

$sql = "update wp_pluck set number='$number' where ID='$produk_id'";

if ($conn->query($sql) === TRUE) {
echo "Records updated: ID ".$produk_id.":".$number;
} else {
echo "Error: ".$sql."<br>".$conn->error;
}

$conn->close();

?>








Tuesday, 12 April 2022

CUSTOM ADMIN DASHBOARD WIDGET SCREEN OPTIONS

 add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');

  
function my_custom_dashboard_widgets() {
global $wp_meta_boxes;
 
wp_add_dashboard_widget('custom_help_widget', 'Theme Support', 'custom_dashboard_help');
}
 
function custom_dashboard_help() {
echo '<p>Welcome to Custom Blog Theme! Need help? Contact the developer <a href="mailto:yourusername@gmail.com">here</a>. For WordPress Tutorials visit: <a href="https://www.wpbeginner.com" target="_blank">WPBeginner</a></p>';
}

WP FUNCTIONS.PHP TO THE WORDPRESS PLUGIN

 1. You need file manager. Download it on plugin

2. Create new folder name it anything 'my-functions'

3. Create new php file name it 'my-functions.php'

4. paste and edit code below suit with your want


<?php

/*

Plugin Name: my functions

Plugin URI:  https://orkedtouch.com/wp-admin/plugin-editor.php

Description: This is my functions instead on functions.php

Author:      MUHAZA

Author URI:  

Version:     2022.04.13

License:     GPL

*/

// add your functions below



Saturday, 9 April 2022

Fonts with specific Media Query

 <link rel="stylesheet" href="styles.css" media="only screen and (max-device-width: 480px)">

<link rel="stylesheet" href="styles_mobile.css" media="only screen and (min-device-width: 480px)">

Friday, 8 April 2022

HTACCESS SPEED UP OPTIMIZE SETUP

php_value upload_max_filesize 64M
php_value post_max_size 128M
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300


# BEGIN DEFLATE COMPRESSION
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
 AddOutputFilterByType DEFLATE application/javascript
 AddOutputFilterByType DEFLATE application/rss+xml
 AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
 AddOutputFilterByType DEFLATE application/x-font
 AddOutputFilterByType DEFLATE application/x-font-opentype
 AddOutputFilterByType DEFLATE application/x-font-otf
 AddOutputFilterByType DEFLATE application/x-font-truetype
 AddOutputFilterByType DEFLATE application/x-font-ttf
 AddOutputFilterByType DEFLATE application/x-javascript
 AddOutputFilterByType DEFLATE application/xhtml+xml
 AddOutputFilterByType DEFLATE application/xml
 AddOutputFilterByType DEFLATE font/opentype
 AddOutputFilterByType DEFLATE font/otf
 AddOutputFilterByType DEFLATE font/ttf
 AddOutputFilterByType DEFLATE image/svg+xml
 AddOutputFilterByType DEFLATE image/x-icon
 AddOutputFilterByType DEFLATE text/css
 AddOutputFilterByType DEFLATE text/html
 AddOutputFilterByType DEFLATE text/javascript
 AddOutputFilterByType DEFLATE text/plain
 AddOutputFilterByType DEFLATE text/xml
</IfModule>
# END DEFLATE COMPRESSION

# BEGIN GZIP COMPRESSION
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# END GZIP COMPRESSION


# BEGIN GZIP COMPRESSION
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# END GZIP COMPRESSION

# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
 <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
 Header set Cache-Control "public"
 </filesMatch>
 <filesMatch "\.(css)$">
 Header set Cache-Control "public"
 </filesMatch>
 <filesMatch "\.(js)$">
 Header set Cache-Control "private"
 </filesMatch>
 <filesMatch "\.(x?html?|php)$">
 Header set Cache-Control "private, must-revalidate"
 </filesMatch>
</ifModule>
# END Cache-Control Headers

WOOCOMMERCE FLYCART

When using woofc or woocommerce flycart font icon will interrupt speed of website.

add_action( 'wp_enqueue_scripts', 'woofc_remove_font_icon', 99 );
function woofc_remove_font_icon() {
wp_dequeue_style( 'woofc-fonts' );
}

Wednesday, 23 February 2022

BASIC DHTML FRONT-END USE

 <script>
        var hello = `data`;
</script>
<!-- DHTML Render -->
<div id=" apps "></div>
<!-- DHTML Start-->
<script>
document.getElementById(" apps ").innerHTML = ` ${hello} All html inside`;
</script>

Sunday, 14 November 2021

PHONE NUMBER OR EMAIL NOT REQUIRED

 // For billing email and phone - Make them not required

add_filter( 'woocommerce_billing_fields', 'filter_billing_fields', 20, 1 );
function filter_billing_fields( $billing_fields ) {
    // Only on checkout page
    if( ! is_checkout() ) return $billing_fields;

    $billing_fields['billing_phone']['required'] = false;
    $billing_fields['billing_email']['required'] = false;
    return $billing_fields;
}

Sunday, 7 November 2021

WP Snippet

 To add code to your header, use this code snippet:

/* Describe what the code snippet does so you can remember later on */
add_action('wp_head', 'your_function_name');
function your_function_name(){
?>
PASTE HEADER CODE HERE
<?php
};

To add code to your footer, use this code snippet:

/* Describe what the code snippet does so you can remember later on */
add_action('wp_footer', 'your_function_name');
function your_function_name(){
?>
PASTE FOOTER CODE HERE
<?php
};

For each snippet, make sure to change:

  • The comment description (helpful when you need to remember what a code snippet does a year later)
  • The your_function_name placeholder (both instances)
  • The PASTE X CODE HERE placeholder

Step 2: Add Code Snippets to functions.php File in Child Theme

Once you have the relevant code snippet(s) ready, you need to add them to the functions.php file of your child theme. You can either edit this file by connecting to your site via FTP. Or, you can go to Appearance → Editor and select the functions.php file. Then, paste your code at the end of the file:

Add code to functions.php file

Add code to functions.php file

Make sure to save your changes and you’re done!

If you want more control over where your header or footer code snippets show up, you can use if statements to only add the code to specific pages on your WordPress site.

For example, to only add code snippets to the header or footer of your homepage, you could use:

/* Describe what the code snippet does so you can remember later on */
add_action('wp_head', 'your_function_name');
function your_function_name(){
if(is_front_page()) {  ?>
PASTE HEADER CODE HERE
<?php  }
};

Another option is to only add the code snippets to specific posts or pages. To do that, you can use this code snippet:

/* Describe what the code snippet does so you can remember later on */
add_action('wp_head', 'your_function_name');
function your_function_name(){
if(is_single(73790)) {  ?>
PASTE HEADER CODE HERE
<?php  }
};

Make sure to replace the example number – 73790 – with the actual ID of the post or page you want to add the code snippets to.

Saturday, 1 May 2021

CHANGE WORDPRESS@ EMAIL DEFAULT TO CUSTOM

 // Change default WordPress email address

add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');
 
function new_mail_from($old) {
return 'yourname@yourdomain.com';
}
function new_mail_from_name($old) {
return 'Your Name';
}
now install this plugin Stop WP Emails Going to Spam

Submit RSSa

 rssing.com