Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../themes/Divi/includes/builder/module/helpers/motion
File: Motion.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class ET_Builder_Module_Helper_Motion {
[2] Fix | Delete
private $START_LIMIT = 0;
[3] Fix | Delete
private $START_MIDDLE = 1;
[4] Fix | Delete
private $END_MIDDLE = 2;
[5] Fix | Delete
private $END_LIMIT = 3;
[6] Fix | Delete
private $START_VALUE = 4;
[7] Fix | Delete
private $MIDDLE_VALUE = 5;
[8] Fix | Delete
private $END_VALUE = 6;
[9] Fix | Delete
private $LENGTH = 7;
[10] Fix | Delete
[11] Fix | Delete
private static $instance;
[12] Fix | Delete
[13] Fix | Delete
public static function instance() {
[14] Fix | Delete
return self::$instance ? self::$instance : ( self::$instance = new self() );
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Returns the Motion Effect value. Which is the merge of Saved and Default values.
[19] Fix | Delete
*
[20] Fix | Delete
* @param string $value, $default_value
[21] Fix | Delete
*
[22] Fix | Delete
* @return string
[23] Fix | Delete
*/
[24] Fix | Delete
public function getValue( $saved_value, $default_value ) {
[25] Fix | Delete
if ( $saved_value === $default_value ) {
[26] Fix | Delete
return $saved_value;
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
$saved_array = explode( '|', $saved_value );
[30] Fix | Delete
$default_array = explode( '|', $default_value );
[31] Fix | Delete
[32] Fix | Delete
if ( sizeof( $saved_array ) !== sizeof( $default_array ) ) {
[33] Fix | Delete
return $saved_value;
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
return implode( '|', array_map( array( 'ET_Builder_Module_Helper_Motion', 'getNonEmpty' ) , $saved_array, $default_array ) );
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* Returns the non-empty value or default.
[41] Fix | Delete
*
[42] Fix | Delete
* @param string $value, $default
[43] Fix | Delete
*
[44] Fix | Delete
* @return string
[45] Fix | Delete
*/
[46] Fix | Delete
public static function getNonEmpty( $value, $default ) {
[47] Fix | Delete
if ( '' === $value ) {
[48] Fix | Delete
return $default;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
return $value;
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Returns start limit.
[56] Fix | Delete
*
[57] Fix | Delete
* @param string $value
[58] Fix | Delete
*
[59] Fix | Delete
* @return int
[60] Fix | Delete
*/
[61] Fix | Delete
public function getStartLimit( $value ) {
[62] Fix | Delete
return $this->get( $this->START_LIMIT, $value );
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Set start limit.
[67] Fix | Delete
*
[68] Fix | Delete
* If limit:
[69] Fix | Delete
* - is not a numeric value, return original motionValue
[70] Fix | Delete
* - is lower then 0, set limit to 0
[71] Fix | Delete
* - is higher then start middle, set limit equal to start middle
[72] Fix | Delete
*
[73] Fix | Delete
* @param int $value
[74] Fix | Delete
* @param string $multi_value
[75] Fix | Delete
*
[76] Fix | Delete
* @return string
[77] Fix | Delete
*/
[78] Fix | Delete
public function setStartLimit( $value, $multi_value ) {
[79] Fix | Delete
$value = $this->to_int( $value, $this->getStartLimit( $multi_value ) );
[80] Fix | Delete
$ranged = $this->range( 0, $this->getStartMiddle( $multi_value ), $value );
[81] Fix | Delete
[82] Fix | Delete
return $this->set( $this->START_LIMIT, $ranged, $multi_value );
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
/**
[86] Fix | Delete
* Returns start limit.
[87] Fix | Delete
*
[88] Fix | Delete
* @param string $value
[89] Fix | Delete
*
[90] Fix | Delete
* @return int
[91] Fix | Delete
*/
[92] Fix | Delete
public function getEndLimit( $value ) {
[93] Fix | Delete
return $this->get( $this->END_LIMIT, $value );
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
/**
[97] Fix | Delete
* Set end limit.
[98] Fix | Delete
*
[99] Fix | Delete
* If limit:
[100] Fix | Delete
* - is not a numeric value, return original motionValue
[101] Fix | Delete
* - is lower then end middle, set limit equal to end middle
[102] Fix | Delete
* - is higher then 100, set limit equal to 100
[103] Fix | Delete
*
[104] Fix | Delete
* @param int $value
[105] Fix | Delete
* @param string $multi_value
[106] Fix | Delete
*
[107] Fix | Delete
* @return string
[108] Fix | Delete
*/
[109] Fix | Delete
public function setEndLimit( $value, $multi_value ) {
[110] Fix | Delete
$value = $this->to_int( $value, $this->getEndLimit( $multi_value ) );
[111] Fix | Delete
$ranged = $this->range( $this->getEndMiddle( $multi_value ), 100, $value );
[112] Fix | Delete
[113] Fix | Delete
return $this->set( $this->END_LIMIT, $ranged, $multi_value );
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* Get start middle.
[118] Fix | Delete
*
[119] Fix | Delete
* @param $value
[120] Fix | Delete
*
[121] Fix | Delete
* @return int
[122] Fix | Delete
*/
[123] Fix | Delete
public function getStartMiddle( $value ) {
[124] Fix | Delete
return $this->get( $this->START_MIDDLE, $value );
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
/**
[128] Fix | Delete
* Set start middle limit.
[129] Fix | Delete
*
[130] Fix | Delete
* If limit:
[131] Fix | Delete
* - is not a numeric value, return original motionValue
[132] Fix | Delete
* - is lower then start limit, set limit equal to start limit
[133] Fix | Delete
* - is higher then end middle, set limit equal to end middle
[134] Fix | Delete
*
[135] Fix | Delete
* @param int $value
[136] Fix | Delete
* @param string $multi_value
[137] Fix | Delete
*
[138] Fix | Delete
* @return string
[139] Fix | Delete
*/
[140] Fix | Delete
public function setStartMiddle( $value, $multi_value ) {
[141] Fix | Delete
$value = $this->to_int( $value, $this->getStartMiddle( $multi_value ) );
[142] Fix | Delete
$ranged = $this->range( $this->getStartLimit( $value ), $this->getEndMiddle( $value ), $value );
[143] Fix | Delete
[144] Fix | Delete
return $this->set( $this->START_MIDDLE, $ranged, $multi_value );
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
/**
[148] Fix | Delete
* Get end middle.
[149] Fix | Delete
*
[150] Fix | Delete
* @param $value
[151] Fix | Delete
*
[152] Fix | Delete
* @return int
[153] Fix | Delete
*/
[154] Fix | Delete
public function getEndMiddle( $value ) {
[155] Fix | Delete
return $this->get( $this->END_MIDDLE, $value );
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
/**
[159] Fix | Delete
* Set end middle limit.
[160] Fix | Delete
*
[161] Fix | Delete
* If limit:
[162] Fix | Delete
* - is not a numeric value, return original motionValue
[163] Fix | Delete
* - is lower then start middle limit, set limit equal to start middle limit
[164] Fix | Delete
* - is higher then end limit, set limit equal to end limit
[165] Fix | Delete
*
[166] Fix | Delete
* @param int $value
[167] Fix | Delete
* @param string $multi_value
[168] Fix | Delete
*
[169] Fix | Delete
* @return string
[170] Fix | Delete
*/
[171] Fix | Delete
public function setEndMiddle( $value, $multi_value ) {
[172] Fix | Delete
$value = $this->to_int( $value, $this->getEndMiddle( $multi_value ) );
[173] Fix | Delete
$ranged = $this->range( $this->getStartMiddle( $value ), $this->getEndLimit( $value ), $value );
[174] Fix | Delete
[175] Fix | Delete
return $this->set( $this->END_MIDDLE, $ranged, $multi_value );
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
/**
[179] Fix | Delete
* Returns option value for start.
[180] Fix | Delete
*
[181] Fix | Delete
* @param string $value
[182] Fix | Delete
*
[183] Fix | Delete
* @return string
[184] Fix | Delete
*/
[185] Fix | Delete
public function getStartValue( $value ) {
[186] Fix | Delete
return $this->get( $this->START_VALUE, $value );
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
/**
[190] Fix | Delete
* Sets option value for start.
[191] Fix | Delete
*
[192] Fix | Delete
* @param string $value
[193] Fix | Delete
* @param string $multi_value
[194] Fix | Delete
*
[195] Fix | Delete
* @return string
[196] Fix | Delete
*/
[197] Fix | Delete
public function setStartValue( $value, $multi_value ) {
[198] Fix | Delete
return $this->set( $this->START_VALUE, $value, $multi_value );
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
/**
[202] Fix | Delete
* Returns option value for middle.
[203] Fix | Delete
*
[204] Fix | Delete
* @param string $value
[205] Fix | Delete
*
[206] Fix | Delete
* @return string
[207] Fix | Delete
*/
[208] Fix | Delete
public function getMiddleValue( $value ) {
[209] Fix | Delete
return $this->get( $this->MIDDLE_VALUE, $value );
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
/**
[213] Fix | Delete
* Sets option value for middle.
[214] Fix | Delete
*
[215] Fix | Delete
* @param string $value
[216] Fix | Delete
* @param string $multi_value
[217] Fix | Delete
*
[218] Fix | Delete
* @return string
[219] Fix | Delete
*/
[220] Fix | Delete
public function setMiddleValue( $value, $multi_value ) {
[221] Fix | Delete
return $this->set( $this->MIDDLE_VALUE, $value, $multi_value );
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
/**
[225] Fix | Delete
* Returns option value for end.
[226] Fix | Delete
*
[227] Fix | Delete
* @param string $value
[228] Fix | Delete
*
[229] Fix | Delete
* @return string
[230] Fix | Delete
*/
[231] Fix | Delete
public function getEndValue( $value ) {
[232] Fix | Delete
return $this->get( $this->END_VALUE, $value );
[233] Fix | Delete
}
[234] Fix | Delete
[235] Fix | Delete
/**
[236] Fix | Delete
* Sets option value for end.
[237] Fix | Delete
*
[238] Fix | Delete
* @param string $value
[239] Fix | Delete
* @param string $multi_value
[240] Fix | Delete
*
[241] Fix | Delete
* @return string
[242] Fix | Delete
*/
[243] Fix | Delete
public function setEndValue( $value, $multi_value ) {
[244] Fix | Delete
return $this->set( $this->END_VALUE, $value, $multi_value );
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
/**
[248] Fix | Delete
* Same as Multi.merge, but applies the elements parameter
[249] Fix | Delete
*
[250] Fix | Delete
* @param string $value_1
[251] Fix | Delete
* @param string $value_2
[252] Fix | Delete
*
[253] Fix | Delete
* @return string
[254] Fix | Delete
*/
[255] Fix | Delete
public function merge( $value_1, $value_2 ) {
[256] Fix | Delete
return $this->to_value( $this->split( $this->multi()->merge( $value_1, $value_2, $this->LENGTH ) ) );
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
/**
[260] Fix | Delete
* Parses array value and converts it to a valid motion array
[261] Fix | Delete
* - array length should be 7
[262] Fix | Delete
* - first 4 values should be numeric values
[263] Fix | Delete
* - first 4 values should respect 0-100 boundaries
[264] Fix | Delete
* - first 4 values should be ordered in ascending order
[265] Fix | Delete
* - last 3 values should be string values
[266] Fix | Delete
*
[267] Fix | Delete
* @param array $value
[268] Fix | Delete
*
[269] Fix | Delete
* @return array
[270] Fix | Delete
*/
[271] Fix | Delete
protected function parse( array $value ) {
[272] Fix | Delete
$arr = $this->multi()->parse( $value, $this->LENGTH );
[273] Fix | Delete
$range = array();
[274] Fix | Delete
[275] Fix | Delete
$range[ $this->START_LIMIT ] = $this->to_int( array_shift( $arr ), 0 );
[276] Fix | Delete
$range[ $this->START_MIDDLE ] = $this->to_int( array_shift( $arr ), 50 );
[277] Fix | Delete
$range[ $this->END_MIDDLE ] = $this->to_int( array_shift( $arr ), 50 );
[278] Fix | Delete
$range[ $this->END_LIMIT ] = $this->to_int( array_shift( $arr ), 100 );
[279] Fix | Delete
[280] Fix | Delete
sort( $range, SORT_NUMERIC );
[281] Fix | Delete
[282] Fix | Delete
$range[ $this->START_LIMIT ] = max( $range[ $this->START_LIMIT ], 0 );
[283] Fix | Delete
$range[ $this->END_LIMIT ] = min( $range[ $this->END_LIMIT ], 100 );
[284] Fix | Delete
$range[ $this->START_MIDDLE ] = max( $range[ $this->START_MIDDLE ], $range[ $this->START_LIMIT ] );
[285] Fix | Delete
$range[ $this->END_MIDDLE ] = min( $range[ $this->END_LIMIT ], $range[ $this->END_MIDDLE ] );
[286] Fix | Delete
[287] Fix | Delete
return array_merge( $range, $arr );
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
/**
[291] Fix | Delete
* Converts a value to a valid motion array value.
[292] Fix | Delete
*
[293] Fix | Delete
* @param string $value
[294] Fix | Delete
*
[295] Fix | Delete
* @return array
[296] Fix | Delete
*/
[297] Fix | Delete
protected function split( $value ) {
[298] Fix | Delete
return $this->parse( $this->multi()->split( $value, $this->LENGTH ) );
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
/**
[302] Fix | Delete
* Converts a value to a valid motion string value.
[303] Fix | Delete
*
[304] Fix | Delete
* @param array $value
[305] Fix | Delete
*
[306] Fix | Delete
* @return string
[307] Fix | Delete
*/
[308] Fix | Delete
protected function to_value( array $value ) {
[309] Fix | Delete
return $this->multi()->to_value( $this->parse( $value ), $this->LENGTH );
[310] Fix | Delete
}
[311] Fix | Delete
[312] Fix | Delete
/**
[313] Fix | Delete
* @return ET_Builder_Module_Helper_Multi_Value
[314] Fix | Delete
*/
[315] Fix | Delete
protected function multi() {
[316] Fix | Delete
return ET_Builder_Module_Helper_Multi_Value::instance();
[317] Fix | Delete
}
[318] Fix | Delete
[319] Fix | Delete
/**
[320] Fix | Delete
* Returns specific key value
[321] Fix | Delete
*
[322] Fix | Delete
* @param int $key
[323] Fix | Delete
* @param string $value
[324] Fix | Delete
*
[325] Fix | Delete
* @return mixed
[326] Fix | Delete
*/
[327] Fix | Delete
protected function get( $key, $value ) {
[328] Fix | Delete
$arr = $this->parse( $this->multi()->split( $value, $this->LENGTH ) );
[329] Fix | Delete
[330] Fix | Delete
return $arr[ $key ];
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
/**
[334] Fix | Delete
* @param int $key
[335] Fix | Delete
* @param $value
[336] Fix | Delete
* @param string $multi_value
[337] Fix | Delete
*
[338] Fix | Delete
* @return string
[339] Fix | Delete
*/
[340] Fix | Delete
protected function set( $key, $value, $multi_value ) {
[341] Fix | Delete
return $this->multi()->set( $key, $value, $multi_value, $this->LENGTH );
[342] Fix | Delete
}
[343] Fix | Delete
[344] Fix | Delete
private function to_int( $value, $default ) {
[345] Fix | Delete
return is_numeric( $value ) ? (int) $value : $default;
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
/**
[349] Fix | Delete
* @param int $min
[350] Fix | Delete
* @param int $max
[351] Fix | Delete
* @param int $value
[352] Fix | Delete
*
[353] Fix | Delete
* @return int
[354] Fix | Delete
*/
[355] Fix | Delete
private function range( $min, $max, $value ) {
[356] Fix | Delete
return min( $max, max( $min, $value ) );
[357] Fix | Delete
}
[358] Fix | Delete
}
[359] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function