Skip to content

Instantly share code, notes, and snippets.

@m4munib
m4munib / gist:8a2a0bd51d9b5f8a05c192d9556f6c27
Created August 4, 2024 13:22
Adding custom event - shopmagic
<?php
class ShopMagicMyCustomEvent extends \WPDesk\ShopMagic\Workflow\Event\Builtin\OrderCommonEvent {
public function get_name() : string {
return __( 'My Custom Event', 'my-text-domain' );
}
public function get_description(): string {
return __( 'My custom event description', 'my-text-domain' );
}
@m4munib
m4munib / HOA
Last active December 25, 2021 19:17
<?php
/**
* Single Listing CT IDX Pro Info
*
* @package WP Pro Real Estate 7
* @subpackage Include
*/
global $ct_options;
<?php
// Usage:
$post_id = 'POST_ID_HERE';
echo idx_get_grouped_features( $post_id );
/**
Example Output:
<div class="idx_grouped_features">
<h4>Interior</h4>
<ul>
@m4munib
m4munib / bytes-to-image-aspnet.cs
Created August 16, 2016 19:14
How to render bytes Image on the fly
try {
byte[] imageBytes = null;
imageBytes = ...; //read image from the disk
if (imageBytes != null)
{
Response.Clear();
Response.ContentType = "image/jpg";
Response.BinaryWrite(imageBytes);
@m4munib
m4munib / envato-api-nodejs-http-request-helper.js
Created May 30, 2016 21:55
Envato API - HTTP Request - Node.js
var httpHelper = require('./helper/http');
var options = {
host: 'marketplace.envato.com',
path: '/api/edge/number-of-files:themeforest.json',
method: "GET",
headers: {'user-agent': 'Node.js - Envato API Consumer'}
};
httpHelper.request(options, function (body) {
@m4munib
m4munib / get-nodejs-http-request-helper.js
Created May 30, 2016 21:53
GET/POST HTTP request Node.js
/*GET Request*/
var httpHelper = require('./helper/http');
var options = {
host: 'www.domain.com',
path: '/example-page',
method: 'GET'
};
httpHelper.request(options, function (body) {
@m4munib
m4munib / nodejs-http-request-helper.js
Created May 30, 2016 20:28
HTTP request helper using Node.js
var http = require('http');
function request(options, callback)
{
http.request(options, function (response) {
var responseBody = '';
response.on('data', function (data) {
responseBody += data;
});
@m4munib
m4munib / user_signup_command.php
Created May 29, 2016 17:07
User Signup using PHP Command Pattern
<?php
class SignupCommand extends AbstractCommand {
private $oUser = null;
private $data = array();
function __construct($oUser, $data) {
$this->oUser = $oUser;
$this->data = $data;
@m4munib
m4munib / php_command_pattern.php
Created May 29, 2016 16:16
Abstract Class - PHP Command
<?php
interface InterfaceCommand {
function execute();
}
abstract class AbstractCommand implements InterfaceCommand {
/**