HEX
Server: nginx
System: Linux pool195-106-36.bur.atomicsites.net 6.12.57+deb12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.57-1~bpo12+1 (2025-11-17) x86_64
User: (0)
PHP: 8.3.32
Disabled: pcntl_fork
Upload Files
File: //srv/htdocs/wp-content/plugins/custom-codes/lib/activation.php
<?php
/**
 * Plugin activation actions.
 *
 * @since   2.0.0
 * @package Custom_Codes
 */

defined( 'ABSPATH' ) || die( 'No script kiddies please!' );


/**
 * Create and give permission to the custom codes directory.
 */
function codes_plugin_activate() {
	global $wp_filesystem;

	if ( empty( $wp_filesystem ) ) {
		include_once ABSPATH . '/wp-admin/includes/file.php';
		WP_Filesystem();
	}

	// Create the folder.
	if ( ! file_exists( CODES_FOLDER_DIR ) ) {
		$wp_filesystem->mkdir( CODES_FOLDER_DIR, 0755 );
	}

	// Give permission.
	if ( ! is_readable( CODES_FOLDER_DIR ) || ! codes_is_writable( CODES_FOLDER_DIR ) ) {
		$wp_filesystem->chmod( CODES_FOLDER_DIR, 0755 );
	}
}
register_activation_hook( CODES_FILE, 'codes_plugin_activate' );




/**
 * Shortcut in the plugins page.
 *
 * @param array $actions Plugin action links array.
 * @param array $file    Returns plugin file name.
 */
function codes_plugins_page_link( $actions, $file ) {

	if ( plugin_basename( CODES_FILE ) === $file ) {

		$actions['settings'] = '<a href="' . admin_url( 'edit.php?post_type=custom-code&page=settings' ) . '">' . __( 'Settings', 'custom-codes' ) . '</a>';

	}

	return $actions;
}
add_filter( 'plugin_action_links', 'codes_plugins_page_link', 2, 2 );




/**
 * Call the translation.
 */
function codes_load_plugin_textdomain() {

	load_textdomain( 'custom-codes', CODES_PLUGIN_DIR . '/languages/custom-codes-' . get_user_locale() . '.mo' );
}
add_action( 'plugins_loaded', 'codes_load_plugin_textdomain' );