المهام

wb_gold_icon
قطعة ذهبية

قم بزيارة موقعنا


100 قطعة ذهبية

اضغط هنا للحصول على 100 شدة

Link to my stuff

افتح صفحة جديدة

<a href="HERE LINK" target="_blank">Open link</a>

افتح صفحة جديدة في نافذة جديدة

<a href="HERE LINK" target="popup" onclick="window.open('HERE LINK','NAME','width=600,height=400')" rel="noopener">Open link</a>

كود النشاط اذا التطبيق منزل او لا

<activity android:name=".MainActivity >
        <intent-filter>
            <data
                android:host="www.myurl.com"
                android:pathPrefix="/openmyapp"
                android:scheme="http" >
            </data>

            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

كود النشاط اذا التطبيق منزل او لا 2

<activity android:name="me.test.html.MainActivity" >
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <data
            android:host="xxxxx"
            android:scheme="mm" />
    </intent-filter>
</activity>
<html>  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
<title>Insert title here</title>  
<script type="text/javascript">
function test2(){
    var di = document.getElementById("di");
    di.innerHTML = "app have not installed";
}
function newOpen(){//184 064 323 438
    var di = document.getElementById("di");
    di.innerHTML = "app have installed";
    var ifc = document.getElementById("ifc");
    ifc.innerHTML = "<iframe src='mm://xxxxx?a=b&c=d' onload='test2()'></iframe>";
    return false;
}
</script>
</head>  
<body>  
 <a href="#" onclick="return newOpen()">local3</a><br/> 
<div id="di"></div> 
 <div style="display:none;" id="ifc"></div>
</body>  
</html>

In this way, when the user clicks the tag, and if the device has the app installed, then it will not show a dialog to let the user choose, but instead open the app directly; and if the app hasn’t been installed, then the js function “test2” will be called, therefore we know that the app has not been installed, so we can do anything in the “test2”! The benefit is that we don’t need to use the standard html schema, which would show a choose dialog, and if I use the defined schema myself, the page would not been navigated to a wrong page! I am a Chinese, my English is not good, hope everyone could understand me and let’s others know the resolution.

لينك لصفحة معينة

<p><a href="http://example.com/">Redirect</a></p>

add custom hook

// Register Hook
add_filter( 'mycred_setup_hooks', 'register_my_custom_hook' );
function register_my_custom_hook( $installed )
{
	$installed['complete_profile'] = array(
		'title'       => __( '%plural% for Profile Completion', 'textdomain' ),
		'description' => __( 'This hook award / deducts points from users who fill out their first and last name.', 'textdomain' ),
		'callback'    => array( 'my_custom_hook_class' )
	);
	return $installed;
}

// myCRED Custom Hook Class
class my_custom_hook_class extends myCRED_Hook {

	/**
	 * Construct
	 */
	function __construct( $hook_prefs, $type = 'mycred_default' ) {
		parent::__construct( array(
			'id'       => 'complete_profile',
			'defaults' => array(
				'creds'   => 1,
				'log'     => '%plural% for completing your profile'
			)
		), $hook_prefs, $type );
	}

	/**
	 * Hook into WordPress
	 */
	public function run() {
		// Since we are running a single instance, we do not need to check
		// if points are set to zero (disable). myCRED will check if this
		// hook has been enabled before calling this method so no need to check
		// that either.
		add_action( 'personal_options_update',  array( $this, 'profile_update' ) );
		add_action( 'edit_user_profile_update', array( $this, 'profile_update' ) );
	}

	/**
	 * Check if the user qualifies for points
	 */
	public function profile_update( $user_id ) {
		// Check if user is excluded (required)
		if ( $this->core->exclude_user( $user_id ) ) return;

		// Check to see if user has filled in their first and last name
		if ( empty( $_POST['first_name'] ) || empty( $_POST['last_name'] ) ) return;

		// Make sure this is a unique event
		if ( $this->has_entry( 'completing_profile', '', $user_id ) ) return;

		// Execute
		$this->core->add_creds(
			'completing_profile',
			$user_id,
			$this->prefs['creds'],
			$this->prefs['log'],
			'',
			'',
			$this->mycred_type
		);
	}

	/**
	 * Add Settings
	 */
	 public function preferences() {
		// Our settings are available under $this->prefs
		$prefs = $this->prefs; ?>

<!-- First we set the amount -->
<label class="subheader"><?php echo $this->core->plural(); ?></label>
<ol>
	<li>
		<div class="h2"><input type="text" name="<?php echo $this->field_name( 'creds' ); ?>" id="<?php echo $this->field_id( 'creds' ); ?>" value="<?php echo esc_attr( $prefs['creds'] ); ?>" size="8" /></div>
	</li>
</ol>
<!-- Then the log template -->
<label class="subheader"><?php _e( 'Log template', 'mycred' ); ?></label>
<ol>
	<li>
		<div class="h2"><input type="text" name="<?php echo $this->field_name( 'log' ); ?>" id="<?php echo $this->field_id( 'log' ); ?>" value="<?php echo esc_attr( $prefs['log'] ); ?>" class="long" /></div>
	</li>
</ol>
<?php
	}

	/**
	 * Sanitize Preferences
	 */
	public function sanitise_preferences( $data ) {
		$new_data = $data;

		// Apply defaults if any field is left empty
		$new_data['creds'] = ( !empty( $data['creds'] ) ) ? $data['creds'] : $this->defaults['creds'];
		$new_data['log'] = ( !empty( $data['log'] ) ) ? sanitize_text_field( $data['log'] ) : $this->defaults['log'];

		return $new_data;
	}
}
  • العربية
  • English
  • Deutsch