This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Am_Di::getInstance()->hook->add(Am_Event::ADMIN_MENU, function(Am_Event $e){ | |
if ($p = $e->getMenu()->findOneById('users-browse')) { | |
$c = $p->getParent(); | |
$c->removePage($p); | |
$c->addPage([ | |
'id' => 'users-browse', | |
'uri' => $e->getDi()->url('admin-users', ['_u_sort' => 'added DESC'], false), | |
'label' => ___('Browse Users'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Am_Di::getInstance()->hook->add(Am_Event::LOAD_ADMIN_DASHBOARD_WIDGETS, function(Am_Event $e) { | |
$e->addReturn(new Am_AdminDashboardWidget('upcoming-expire', ___('Upcoming Expirations'), | |
function(Am_View $v, $config = null) { | |
$lookahead = sqlDate('+7 days'); | |
$now = sqlDate('now'); | |
$data = Am_Di::getInstance()->db->select(<<<CUT | |
SELECT u.login, u.email, u.name_f, u.name_l, product_id, MAX(expire_date) AS exp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Am_Di::getInstance()->hook->add(Am_Event::AUTH_GET_OK_REDIRECT, function(Am_Event $e) { | |
/* @var $user User */ | |
$user = $e->getUser(); | |
if (stripos($e->getReturn(), '/signup') !== false) { | |
$e->setReturn($e->getDi()->url('member', false)); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Am_Di::getInstance()->hook->add([Am_Event::MAIL_TEMPLATE_BEFORE_PARSE, Am_Event::MAIL_SIMPLE_TEMPLATE_BEFORE_PARSE], function(Am_Event $e) { | |
$e->getMail()->setReturnPath('[email protected]'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Am_Di::getInstance()->hook->add(Am_Event::BEFORE_RENDER, function (Am_Event $e) { | |
if (stripos($e->getTemplateName(), '/login.phtml') !== false) { | |
$e->getView()->signup_url = '/your/custom/url'; | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Am_Di::getInstance()->hook->add(Am_Event::AFTER_RENDER, function(Am_Event_AfterRender $e) { | |
if (defined('AM_ADMIN') && AM_ADMIN) return; | |
if ( | |
stripos($e->getOutput(), 'There are no products available for purchase. Please come back later') !== false | |
&& $e->getDi()->request->getControllerName() == 'signup' | |
) { | |
$url = $e->getDi()->url('no-product', ['c' => $e->getDi()->request->getParam('c')], false); | |
header("Location: {$url}"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Am_Di::getInstance()->hook->add(Am_Event::INVOICE_GET_CALCULATORS, function(Am_Event_InvoiceGetCalculators $e){ | |
$e->insertBeforeTax(new class() extends Am_Invoice_Calc | |
{ | |
public function calculate(Invoice $invoiceBill) | |
{ | |
$discount_rules = [ | |
108 => [ //Product ID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Am_Di::getInstance()->hook->add(Am_Event::VALIDATE_COUPON, function(Am_Event $e) { | |
$batch = $e->getCouponBatch(); | |
$coupon = $e->getCoupon(); | |
$used = $e->getDi()->invoiceTable->countBy([ | |
'coupon_id' => $coupon->pk(), | |
'remote_addr' => $_SERVER['REMOTE_ADDR'] | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Use click event to add Brick to Form | |
*/ | |
Am_Di::getInstance()->hook->add('gridSavedFormInitForm', function(Am_Event_Grid $e) { | |
$e->getGrid()->getForm() | |
->addScript() | |
->setScript(<<<'CUT' | |
let drag = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(function(){ | |
jQuery(window).resize(function(){ | |
jQuery('iframe.embed-video-16-9').each(function(){ | |
jQuery(this).height(jQuery(this).width() * 9/16) | |
}); | |
}).resize(); | |
}); |